MATLAB: Plotting and reversing axis direction

plottingreverse direction.two y axes

Hello, I want to plot a graph with one x axis and two y axes. I want one of the y axes to be reversed i.e. beginning at the top so the data hangs off the top of the graph. Additionally I want the reversed y axis plot to be a bar graph and the other to be an ordinary line plot.
I tried this function
plot (a,b)
bar(a,c)
Set (gca,'Ydir','reverse')
but this reversed both y axes.

Best Answer

a = (1:10)';
b = rand(10, 1);
c = rand(10, 1);
figure
h1 = axes
bar(a, c)
set(h1, 'Ydir', 'reverse')
set(h1, 'YAxisLocation', 'Right')
h2 = axes
plot(a,b)
set(h2, 'XLim', get(h1, 'XLim'))
set(h2, 'Color', 'None')
set(h2, 'Xtick', [])