Log axis with percentage tick labels
Show older comments
Hi, just starting to use matlab here, running a few experimental calculations and pretty excited so far.
I'm currently struggling with displaying a graph of cumulative relative returns where changing value axis scale to log seems to defeat percentage formatting and override it with a default format, making presentation hard to grasp.
figure;
ax = axes;
plot(sourceData.Date, sourceData.ResultCompound);
ytickformat(ax, 'percentage'); % also tried ytickformat(ax, '%0.2f%%')
ax.YScale = 'log'; % no problem with default/'linear'
So my question is, is there a way to make log-scaled graphs with percentage tick labels?
Accepted Answer
More Answers (1)
Steve Eddins
on 24 Sep 2020
From what I can tell, the ruler object ignores the TickLabelFormat property (which is set by ytickformat) when the Scale is 'log'. I will record an enhancement/documentation request about this.
As a workaround, you can set the tick labels directly to whatever strings you want by using yticklabels. Try something like this:
yticklabels(string(yticks) + "%")
2 Comments
Dmitriy Saltanov
on 24 Sep 2020
Steve Eddins
on 24 Sep 2020
Thanks, Dmitriy. I have your comments to the enhancement request record.
Categories
Find more on Axis Labels 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!