Removing scientific notation in log plot

조회 수: 25 (최근 30일)
John Carroll
John Carroll 2022년 6월 8일
댓글: Voss 2022년 6월 8일
Hello
I am trying to plot some data with the x axis in log scale. However as a result I seem to be getting x axis labeling in scientific notation and I would prefer simple integers. I am using the following code to create the graph.
figure('Name','2D Tunability')
plot(FreqS,Tunability2D,'k','LineWidth',2)
axis([0.1 20 min(Tunability2D)/1.01 max(Tunability2D)*1.01])
set(gca,'fontsize', 20)
set(gca, 'XScale', 'log')
The x variable is 0.1 to 20 in 0.1 steps and I have the y axis set to scale based on the data. But the x axis shows up in powers of 10. I would rather see it shown as 0.1, 1 10, 20 if possible. I have tried using the xtickformat command but it doesn't seem to have any effect on the plot. I'd also like to manually pick with tick point appear on the laabel if possible.
Thanks in advance

채택된 답변

Voss
Voss 2022년 6월 8일
FreqS = 0.1:0.1:20;
Tunability2D = rand(1,numel(FreqS));
figure('Name','2D Tunability')
plot(FreqS,Tunability2D,'k','LineWidth',2)
axis([0.1 20 min(Tunability2D)/1.01 max(Tunability2D)*1.01])
set(gca, 'fontsize', 20, 'XScale', 'log')
% set the x-tick values:
xtick = [0.1 1 10 20];
xticks(xtick);
% set the x-tick labels, if you want:
% (but setting just the x-tick values seems to work ok in this case)
% xticklabels(xtick);
  댓글 수: 2
John Carroll
John Carroll 2022년 6월 8일
This worked perfect thank you
Voss
Voss 2022년 6월 8일
You're welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by