Borrar filtros
Borrar filtros

writing all numbers on x axes with plot function

27 visualizaciones (últimos 30 días)
sermet
sermet el 22 de Nov. de 2014
Comentada: Star Strider el 22 de Nov. de 2014
%for example
id=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
north=[100;101;102;103;104;105;106;107;108;109;110;111;112;113;114];
figure;
plot(id,north,'b')
title('NORTH-COORDINATE TIME SERIES')
xlabel('SESSIONS')
ylabel('NORTH')
%I want that every number of id appears on the x axes (not, 0-5-10-15) in the figure.

Respuesta aceptada

Star Strider
Star Strider el 22 de Nov. de 2014
Add a command to specify the 'XTick' values to put every value of ‘id’ on the x-axis:
id=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
north=[100;101;102;103;104;105;106;107;108;109;110;111;112;113;114];
figure;
plot(id,north,'b')
title('NORTH-COORDINATE TIME SERIES')
xlabel('SESSIONS')
ylabel('NORTH')
set(gca, 'XTick',id) % Specify XTick Values
  2 comentarios
sermet
sermet el 22 de Nov. de 2014
I applied it but sometimes id numbers are quite high like (200-150) then it doesn't seem properly on the x axes in the figure. Is this a way that all numbers are visible even they are too many.
Star Strider
Star Strider el 22 de Nov. de 2014
Probably the easiest way is to reduce the FontSize:
id=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
north=[100;101;102;103;104;105;106;107;108;109;110;111;112;113;114];
figure;
plot(id,north,'b')
title('NORTH-COORDINATE TIME SERIES', 'FontSize',12)
xlabel('SESSIONS', 'FontSize',10)
ylabel('NORTH', 'FontSize',10)
set(gca, 'XTick',id, 'FontSize',7) % Specify XTick Values
This reduces the font size on all axes tick labels and everything else as well, so you have to set the title and axis labels individually, as I did here.
In R2014b, you can easily rotate the tick labels so they won’t overlap. If the tick labels are densely packed, you may want to plot every other one or every fifth one, for instance. If you have R2014a or earlier, you will have to specify the 'XTickLabel' values as a cell array of strings, and rotate them using the Text Properties command functions.
The easiest way to deal with densely packed tick labels is simply to display fewer of them.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by