Dividing x tick labels

조회 수: 26 (최근 30일)
Richard Rees
Richard Rees 2020년 2월 23일
답변: Image Analyst 2020년 2월 23일
Quick question. I have divided my xaxis labels by 10 using the following code
xt = get(gca,'xtick');
set(gca,'XTick',xt, 'xticklabel',xt/10)
The last time I used this code, the tick intervals would remain the same but this time the xtick intervals have also been divided by 10 and is only showing a single tick label (see graphs). I have tried tinkering with the intervals and using the xlims but the problem remains. I don't understand why it is doing it.
  댓글 수: 1
Sai Bhargav Avula
Sai Bhargav Avula 2020년 2월 23일
can you show what is the result of the
xt = get(gca,'xtick');
I believe the issue is with the xt itself

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2020년 2월 23일
Why not simply use xticks() to set whatever tick marks you want, like
% Create some sample plot:
hFig = figure;
plot(1:10)
% Get current axes limits in the x direction.
xl = xlim
% Make 15 values from the left side to the right side.
xt = linspace(xl(1), xl(end), 15);
% Apply these tick mark values to the graph, drawing these new ones on the graph.
xticks(xt);
% Make a grid.
grid on
% Maximize the figure.
hFig.WindowState = 'maximized'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by