필터 지우기
필터 지우기

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 (최근 30일)
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

채택된 답변

Star Strider
Star Strider 2023년 7월 30일
편집: Star Strider 2023년 7월 30일
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’.
.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 7월 30일
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.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by