How do I add minor ticks to a graph?

882 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 30 de Mayo de 2012
Comentada: KAE el 9 de Abr. de 2019
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.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 30 de Mayo de 2012
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.

Más respuestas (1)

Matt
Matt el 15 de Nov. de 2014
Editada: Matt el 15 de Nov. de 2014
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 comentarios
Walter Roberson
Walter Roberson el 1 de Nov. de 2018
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 el 9 de Abr. de 2019
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

Iniciar sesión para comentar.

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by