필터 지우기
필터 지우기

How to add ytick as we want in Matlab?

조회 수: 1 (최근 30일)
Heri Purnawan
Heri Purnawan 2024년 2월 16일
댓글: Star Strider 2024년 2월 16일
If I have data for example
mean = [10^-3, 10^-4, 10^-5, 10^-6, 10^-7, 10^-8] and
variance = [10^0, 10^-1, 10^-2, 10^-3, 10^-4, 10^-5]
I try to plot it in Matlab but the results are not like I want. My code in Matlab is like this. However, I want to set axis-y with 10^{-9}, 10^{-8}, ..., 10^1.
mean = [10^-3, 10^-4, 10^-5, 10^-6, 10^-7, 10^-8];
variance = [10^0, 10^-1, 10^-2, 10^-3, 10^-4, 10^-5];
yaxis = 1:1:6;
figure(1)
plot(yaxis,mean,'b-*',yaxis,variance,'r--*','MarkerIndices',1:1:length(yaxis))
xlim([0 7])
ylim([1e-9 5]);
xlabel('gPC order','interpreter','latex','FontSize',13);
ylabel('error','interpreter','latex','FontSize',13);
set(gca, 'ytick', 1e-9:10:5);
set(gca, 'xtick', 0:1:7);

채택된 답변

Star Strider
Star Strider 2024년 2월 16일
Perhaps setting the 'YScale' to 'log' will do what you want —
mean = [10^-3, 10^-4, 10^-5, 10^-6, 10^-7, 10^-8];
variance = [10^0, 10^-1, 10^-2, 10^-3, 10^-4, 10^-5];
yaxis = 1:1:6;
figure(1)
plot(yaxis,mean,'b-*',yaxis,variance,'r--*','MarkerIndices',1:1:length(yaxis))
xlim([0 7])
ylim([1e-9 5]);
xlabel('gPC order','interpreter','latex','FontSize',13);
ylabel('error','interpreter','latex','FontSize',13);
set(gca, 'YScale','log')
% set(gca, 'ytick', 1e-9:10:5);
% set(gca, 'xtick', 0:1:7);
.
  댓글 수: 2
Heri Purnawan
Heri Purnawan 2024년 2월 16일
Thanks
Star Strider
Star Strider 2024년 2월 16일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

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