How to set the step size in z axis?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello All, I am having a bit difficulty in setting the step size of the graph.
Currently on Z axis I am plotting pressure which is calculated from lot of things. So my current code is:
zlabel('pressure (MPa)')
colorbar
Now by default the Z axis is equally divided with 100 MPa steps which I want to increase it to 200 MPa steps. The issue is for every calculation the max of pressure changes so does the graph and hence I can not add zlim[ ] in it. But still I want only change the step size.
Can anyone help me?
댓글 수: 0
답변 (1개)
dpb
2016년 6월 8일
편집: dpb
2016년 6월 8일
To keep the autoranging limits if they're ok and using a tick spacing of 100, but you want 200, simply
ztk=get(gca,'ztick'); % retrieve current tick locations
set(gca,'ztick',ztk(1z1:2:end)) % setting new ticks at half spacing
If you need to readjust the start value, you'll have to query the min/max from each data set and determine a suitable zlim range and ztick spacing but sounds as though you're ok with the auto range, just want to change the number of ticks...above will reduce by a factor of two beginning with the first; if it were an odd value and you wanted the evens, you'd have to check the value of the first element in ztk and see if want to start with ztk(1) or ztk(2), that is
iz1=mod(ztk(1),200)==100+1; % first index in default ztick divisible by 200
Demo: try
surf(20*peaks(50))
ztk=get(gca,'ztick');
iz1=mod(ztk(1),200)+1;
pause(2) % delay to see initial plot before
set(gca,'ztick',ztk(1:2:end)) % reset z tick spacing
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!