フィルターのクリア

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 Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by