Borrar filtros
Borrar filtros

How to add ytick as we want in Matlab?

1 visualización (últimos 30 días)
Heri Purnawan
Heri Purnawan el 16 de Feb. de 2024
Comentada: Star Strider el 16 de Feb. de 2024
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);

Respuesta aceptada

Star Strider
Star Strider el 16 de Feb. de 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);
.
  2 comentarios
Heri Purnawan
Heri Purnawan el 16 de Feb. de 2024
Thanks
Star Strider
Star Strider el 16 de Feb. de 2024
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by