How to adjust plot scaling/divisions

154 views (last 30 days)
Charles Kubeka
Charles Kubeka on 29 Jul 2015
Edited: dpb on 30 Jul 2015
Hi Everyone, I have the following plots:
I want to show the values between the limits 1000 and 500 on the y-axes. MATLAB automatically chooses to show only the limit values. I would appreciate any help on this.Thanks.

Accepted Answer

dpb
dpb on 29 Jul 2015
Edited: dpb on 29 Jul 2015
ylim([500 1000])
doc ylim % for details
"...the intermediate values still don't show"
Then set ticks where you want them...
set(gca,'ytick',[500:100:1000])
Hadn't actually noticed the two axes as the color on the RH one is quite light and doesn't show well...anyway, presuming that it's plotyy, there are two axes handles from a call such as
hAx=plotyy(xL,yL,xR,yR); % where the two axes handles are in hAx
Now use those two handles in the call to ylim and to set the tick values...or, since know want each just make a single call to set
set(hAx(1),'ylim',[500 1000],'ytick',[500:100:1000]) % LH axes
Now repeat with desired values for the RH axes as
set(hAx(2), 'ytick',[0:100:500]) % RH axes
  4 Comments
Charles Kubeka
Charles Kubeka on 29 Jul 2015
Perfect! Thanks a million dpb.
dpb
dpb on 29 Jul 2015
Edited: dpb on 30 Jul 2015
You're welcome...note if you have a newer release there are methods to set most all the graphics properties rather than using set directly, but I don't much see the point in writing
ax.XTick = [-3:1:3];
ax.XTickLabel = {'-3\pi','-2\pi','-\pi','0','\pi','2\pi','3\pi'};
as compared to
set(ax, 'XTick', [-3:1:3], ...
'XTickLabel',{'-3\pi','-2\pi','-\pi','0','\pi','2\pi','3\pi'})
The methods require two separate statements whereas with the set call you can set all properties for a given axes in one call.
Or, you can use the array version and handle multiple axes and values for each in one call. It seems to me like a case of OO simply for it's own sake rather than providing anything additional in either functionality or in syntax.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!