Multiple x axis top and bottom and left and right y axis
2 views (last 30 days)
Show older comments
I am trying to plot 3 curves two of which use (left and bottom) axes and one curve uses different axes limits set by the top and right axes. The problem I am having is I am unable to click on the points to edit properties of the first two curves. I can edit the last curve. I need to be able to click on the points for using ezyfit.m to fit the 3 curves. Following is my code.
figure %Construct the left Y-axes ax1=axes('XAxisLocation','bottom',... 'YAxisLocation','left',... 'Color','none',... 'XColor','k',... 'YColor','k',... 'YLim',[4 10],'NextPlot','add');
% Construct the right Y-axis ax2=axes('XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none',... 'XColor','r',... 'YColor','r',... 'YLim',[1.6 3.2]);
% Put the labels of all the axes xlabel(ax1,'xlabel 1') ylabel(ax1,'ylabel 1') ylabel(ax2,'ylabel 2')
% Plot the datasets in appropriate axes plot(ax1,xdata1,ydata1,'color','b','linestyle','none','marker','x'); plot(ax1,xdata2,ydata2,'color','k'); plot(ax2,xdata3,ydata3,'color','r');
What am I am doing wrong that makes the datasets 1 and 2 unclickable. Thanks in advance.
0 Comments
Answers (1)
ANKUR KUMAR
on 5 Oct 2018
You can use as many Y axis you want with the help of add axis function available on matlab file exchange. Get addaxis fuction from here .
example:
x = 0:.1:4*pi;
plot(x,sin(x));
addaxis(x,sin(x-pi/3));
addaxis(x,sin(x-pi/2),[-2 5],'linewidth',2);
addaxis(x,sin(x-pi/1.5),[-2 2],'r-','linewidth',2);
addaxis(x,5.3*sin(x-pi/1.3),':','linewidth',2);
See Also
Categories
Find more on Annotations 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!