Clear Filters
Clear Filters

How can we plot on right Y axis?

89 views (last 30 days)
kanyvt
kanyvt on 10 Apr 2015
Commented: KL on 12 Apr 2015
Is there any way to use the right hand side of the y- axis graph to plot the curve?

Accepted Answer

KL
KL on 10 Apr 2015
You can use YAxisLocation. Check the below link.
  2 Comments
kanyvt
kanyvt on 12 Apr 2015
Thanks for the link. But I don't really understand from it. Could you please write some syntax for the same?
KL
KL on 12 Apr 2015
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
hl1 = line(x1,y1,'Color','r');
ax1 = gca;
set(ax1,'XColor','r','YColor','r')
ax2 = axes('XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');
hl2 = line(x2,y2,'Color','k','Parent',ax2);

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!