How to add ytick as we want in Matlab?

2 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Star Strider
Star Strider il 16 Feb 2024
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);
.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by