How to add ytick as we want in Matlab?

1 次查看(过去 30 天)
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);
.

更多回答(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