How do I add minor ticks to a graph?
조회 수: 749 (최근 30일)
이전 댓글 표시
I would like to add minor ticks in between the major ticks. I would like to know if there is a function or a property which will allow me to do this.
채택된 답변
MathWorks Support Team
2012년 5월 30일
There are three properties of axes that allow you to add minor ticks to the axes. They are:
Property NameProperty Values
------------- ---------------
XMinorTick[on,{off}]
YMinorTick[on,{off}]
ZMinorTick[on,{off}]
Below is an example of how to use them:
plot(1:10)
set(gca,'XMinorTick','on','YMinorTick','on')
It is not possible to specify the location of the minor tick marks. Refer to the related solution for a workaround.
댓글 수: 0
추가 답변 (1개)
Matt
2014년 11월 15일
편집: Matt
2014년 11월 15일
Note that as of 2014B it looks like you should be able to edit the location of the minor tick marks directly. This only seems to work though if the minor ticks are already showing.
hA = gca;
%Tick properties can be set in the X/Y/ZRuler.MinorTicks
hA.YRuler.MinorTicks
%Tick locations can be set in the X/Y/ZRuler.MinorTick
hA.Yruler.MinorTick = [0.1:0.1:0.9]
댓글 수: 2
Walter Roberson
2018년 11월 1일
That property is still available in R2018b, for all four regular ruler types (numeric, duration, datetime, categorical).
The property is not available for map axes. It is not immediately clear to me what the map axes equivalent would be.
The property is not exactly available for polaraxes, because polaraxes have RAxis and ThetaAxis rather than XAxis and YAxis. However, RAxis and ThetaAxis both have MinorTickValues properties.
KAE
2019년 4월 9일
Here is an example that worked for me in R2019a,
figure;
plot(rand(10,1), rand(10,1), '.'); % Example plot
h = gca; % Get axis to modify
h.XAxis.MinorTick = 'on'; % Must turn on minor ticks if they are off
h.XAxis.MinorTickValues = -1:0.03:1; % Minor ticks which don't line up with majors
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!