How to reverse x-axis in a stacked plot.
Show older comments
I have used the code below to plot a stacked plot,
X = [4 3 2 1];
x = X';
Y = [2 3 4 5; 3 4 5 6];
y = Y';
plot1=stackedplot(x,y)
The returned plot has a x-direction from min value to max value, how can I modify the code to make it from max to min as the X data presented?

Accepted Answer
More Answers (2)
You can get the axis handles in stackedplot using the undocumented NodeChildren property.
x = [4 3 2 1];
y = [2 3 4 5; 3 4 5 6]';
h = stackedplot(x,y);
set(findobj(h.NodeChildren,'Type','Axes'),'XDir','reverse')
Fangjun Jiang
on 22 Apr 2020
This is interesting. I wonder if this meets your need.
%%
x=1:4;
y=rand(size(x));
plot(y,x);
xlabel('y');
ylabel('x');
axis ij
view(90,-90);
1 Comment
Adam Danz
on 19 Nov 2020
Error using view (line 63)
Using view with stackedplot is not supported.
Categories
Find more on Data Distribution Plots 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!
