Programmatically change stackedplot ticks in live editor
4 次查看(过去 30 天)
显示 更早的评论
I have a stackedplot in a live script where I want to scale up the x axis labels - the values are e.g. 0.01, which i would like to read 10 without changing the data or having to adjust existing limits.
In a regular plot, that works by just editing the XTickLabels. For the stackedplot, a trick is needed to access the axis properties as described here: https://de.mathworks.com/matlabcentral/answers/486898-change-yticks-using-a-stacked-plot#answer_550223
In a normal script, the following code works fine, but in a live script, the plot does not change even though the axis property has changed as the output of the last line confirms.
x = [0 0.01 0.02 0.03];
y1 = [1 2 3 4]';
y2 = [4 3 2 1]';
s = stackedplot(x, [y1 y2]);
xlim([0 0.02]);
axs = findobj(s.NodeChildren, 'Type', 'Axes');
axs(1).XTickLabel = num2str(axs(1).XTick'*1000);
axs(1).XTickLabel
How do I get the live script plot to change?
2 个评论
Paul Kaufmann
2021-10-5
What is wrong with just scaling the x-axis within stackedplot?
s = stackedplot(x * 1000, [y1 y2]);
This doesn't change the data and does what you want. Or am I missing something?
回答(1 个)
Ashutosh Singh Baghel
2021-11-18
Hi Lima,
I understand you wish to have custom XtickLabel in the live script's 'stackedplot' function call. The issue is due to the cause that ' stackedplot ' is not updating the 'XtickLabel' as it should do, although our development team is aware of the issue and investigating.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!