NOTE: Question has been updated.
Hello all,
I want to plot a matrix (37 x 10) represented by sum_ET10 with 2 different y axis scales; km^3/year (original unit) on y axis lhs & mm/year (new unit) on y axis rhs. My code is shown below; I have also included an image below. Currently, my graph is still incorrect. What I want to do is to have a single plot as opposed to the two plots that I'm getting
%% Getting a 37 x 10 matrix of sum_ET10 & sum_area
decade = 10;sum_area = squeeze(sum(reshape(area,size(area,1),decade,[]),2)/10);sum_ET10 = squeeze(sum(reshape(ET,size(ET,1),decade,[]),2)/10);% Plot the results
x_decade = 1:10;f1 = figure(1);x1 = axes;plot(x_decade,sum_ET10(1,:),'-ok');% Query the YTicks
yt = get(x1,'YTick');% Create new axis based on existing axis
x2 = copyobj(x1,f1);% Set new axis transparent
set(x2,'Color','none')% Remove XTicks
set(x2,'Xtick',[])% Display the YTicks on the right side
set(x2,'YAxisLocation','right')% Converting values to mm/year
mm_sum_ET10 = yt/2199000*1000000;% Update labels
set(x2,'YTickLabel',mm_sum_ET10)grid on;xlabel(x1,'Decade');ylabel(x1,'km^3/year');ylabel(x1,'mm/year');
Any help is appreciated. This is my first time doing different scaled axes, so I'm in need of help.
Thank you.
Best Answer