Running an error when attempting to set gca YTick marks.
3 views (last 30 days)
Show older comments
Brianna Florio
on 9 Jul 2018
Commented: Star Strider
on 9 Jul 2018
I have the following code:
set(gca,'YTick',energy_pixel);
However, I'm running an error that says:
Error using matlab.graphics.axis.Axes/set
Value must be a vector of type single or double whose values increase
But my energy_pixel variable is of type double and is either remaining the same or increasing:
energy_pixel = [0, 0, 0, 0, 71, 188, 595, 996]
Is there anyway to allow these numbers to be added to YTick? I can't change the values and I was wondering if there was a way I can work around the error itself.
0 Comments
Accepted Answer
Star Strider
on 9 Jul 2018
We need more information about the values you’re plotting.
Experiment with this:
yt = get(gca, 'YTick');
energy_pixel = compose('%d', [0, 0, 0, 0, 71, 188, 352, 595, 996]);
set(gca, 'YTick',yt, 'YTickLabel',energy_pixel);
The compose function requires R2016b or later.
2 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!