MATLAB: I need to reverse the X axis in a stacked plot graph. How to do that

reverse x-axisstackedplot

I ploted a X,Y stacked graphic
stackedplot(X,Y)

Best Answer

That is not one of the options for the stackedplot function, although it is easy enough to do in code:
x = linspace(0, 1); % Create Data

y = sin(2*pi*x'*[1 5 7]) + exp(x'*[0.5 1.5 2.5]); % Create Data
figure
stackedplot(x, y); % ‘Normal’ Plot
figure
stackedplot(fliplr(x), y); % Use Appropriate ‘flip’ Function To Reverse The ‘X’-Axis Direction
Note that here, ‘x’ is a row vector and ‘y’ is a matrix of column vectors, so use the appropriate ‘flip’ function for the x-axis. .
Experiment to get the result you want.