How to adjust plot scaling/divisions

38 vues (au cours des 30 derniers jours)
Charles Kubeka
Charles Kubeka le 29 Juil 2015
Modifié(e) : dpb le 30 Juil 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.

Réponse acceptée

dpb
dpb le 29 Juil 2015
Modifié(e) : dpb le 29 Juil 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 commentaires
Charles Kubeka
Charles Kubeka le 29 Juil 2015
Perfect! Thanks a million dpb.
dpb
dpb le 29 Juil 2015
Modifié(e) : dpb le 30 Juil 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by