Programmatically change stackedplot ticks in live editor
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Paul Kaufmann
am 5 Okt. 2021
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?
Antworten (1)
Ashutosh Singh Baghel
am 18 Nov. 2021
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 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!