フィルターのクリア

How do I add minor ticks to a graph?

631 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2012 年 5 月 30 日
コメント済み: KAE 2019 年 4 月 9 日
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
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.

その他の回答 (1 件)

Matt
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
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
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 ExchangePolar Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by