Borrar filtros
Borrar filtros

Hello I hope you are well I would like to ask you how I adjust the mark values on the X-axis in multiples of 3 or per unit so that the 24 points are observed. Thank you very m

1 visualización (últimos 30 días)
Hello I hope you are well I would like to ask you how I adjust the mark values on the X-axis in multiples of 3 or per unit so that the 24 points are.
fig=figure(1);
clf;
x1 = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23];
y1 = [0 0 0 0 0 0 4 60 3.8 3.8 3.9 5 3 4 3.7 3.5 3.5 3.5 4 3 2.7 2.5 2 2 ];
plot(x1,y1,"-black*")
% cm = gray(5); % Define 'colormap'
% for k = 1:numel(b1)
% b1(k).CData = cm(k+1,:); % Loop To Set Colours
% end
hold on
x1 = categorical(["0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; "10"; "11"; "12"; "13" ;"14"; "15"; "16"; "17"; "18"; "19"; "20"; "21"; "22"; "23"]);
ylim([0 65])
hold off
% xtickangle(45)
% xticklabels({'00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'});
Tamano_letras_ejes=6.3; % tamño de las etiquetas en los ejes
ax = gca;
ax.FontSize = Tamano_letras_ejes;
xlabel("Horas de ocurrencia, h");
ylabel("Porcentaje de ocurrencia de AT, %");
observed. Thank you very much

Respuesta aceptada

Star Strider
Star Strider el 30 de Jul. de 2023
Editada: Star Strider el 30 de Jul. de 2023
I am not certain what you want.
Try this —
fig=figure(1);
clf;
x1 = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23];
y1 = [0 0 0 0 0 0 4 60 3.8 3.8 3.9 5 3 4 3.7 3.5 3.5 3.5 4 3 2.7 2.5 2 2 ];
plot(x1,y1,"-black*")
% cm = gray(5); % Define 'colormap'
% for k = 1:numel(b1)
% b1(k).CData = cm(k+1,:); % Loop To Set Colours
% end
hold on
x1 = categorical(["0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; "10"; "11"; "12"; "13" ;"14"; "15"; "16"; "17"; "18"; "19"; "20"; "21"; "22"; "23"]);
ylim([0 65])
hold off
% xtickangle(45)
% xticklabels({'00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'});
Tamano_letras_ejes=6.3; % tamño de las etiquetas en los ejes
ax = gca;
ax.FontSize = Tamano_letras_ejes;
xlabel("Horas de ocurrencia, h");
ylabel("Porcentaje de ocurrencia de AT, %");
Ax = gca;
Ax.XTick = 0:24;
Ax.XTickLabel = [string(0:3:24); repmat("",2,9)];
Ax.XTickLabelRotation = 0;
This produces hourly ticks with tick labels every 3 hours.
EDIT — Added ‘XTickLabelRotation’.
.

Más respuestas (1)

Walter Roberson
Walter Roberson el 30 de Jul. de 2023
Use xticks to set the tick positions.
There is no simple way to configure "as the x limits change due to resize or zoom or pan, change the tick positions to maintain tick every 3" -- xticks() configure the tick positions to the given locations until you change them or the axes is reset. It is possible to hook into notifications about the axes limits changing to call a function to set new xticks(), but there is no simple way to set an algorithm to determine the x tick positions as the axes changes.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by