How to adjust plot scaling/divisions

조회 수: 48 (최근 30일)
Charles Kubeka
Charles Kubeka 2015년 7월 29일
편집: dpb 2015년 7월 30일
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.

채택된 답변

dpb
dpb 2015년 7월 29일
편집: dpb 2015년 7월 29일
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
Charles Kubeka
Charles Kubeka 2015년 7월 29일
Perfect! Thanks a million dpb.
dpb
dpb 2015년 7월 29일
편집: dpb 2015년 7월 30일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by