How do I set a limit on a secondary yaxis using an error bar plot?

5 visualizaciones (últimos 30 días)
Victoria Wilson
Victoria Wilson el 24 de Mzo. de 2020
Comentada: Victoria Wilson el 30 de Mzo. de 2020
I have an errorbar plot with two yaxis using yyaxis, I can limit the left axis (yyaxis left) with ylim ([min max]), however it won't work for the right axis (yyaxis right). Any help would be appreciated!!
subplot(5,1,1);
x = Nutrients1{:,3};
y = Nutrients1{:,4};
err = Nutrients1{:,5};
errorbar(x,y,err,'r');
yyaxis left;
ylim([1.2 1.9]);
ylabel('conc. (\muM)');
set(gca,'FontSize',12);
hold on;
x = Nutrients1{:,3};
y = Nutrients1{:,6};
err = Nutrients1{:,7};
errorbar(x,y,err,'b');
yyaxis right;
ylim([0.08 1.13]); % doesn't work???
ylabel('conc. (\muM)');
set(gca,'FontSize',12);

Respuestas (1)

Sindhu Karri
Sindhu Karri el 27 de Mzo. de 2020
I have tried changing the limits to right axes by running a similar example and it works fine. Can you attach the nutrients1variable if possible so that I can be more precise.
  1 comentario
Victoria Wilson
Victoria Wilson el 30 de Mzo. de 2020
Thanks for the effort, I solved it... Pretty simple, I had to put the axis assignment before the plot.
So like this...
subplot(5,1,1);
x = Nutrients1{:,3};
y = Nutrients1{:,4};
err = Nutrients1{:,5};
yyaxis left;
errorbar(x,y,err,'r');
ylim([1.2 1.9]);
ylabel('conc. (\muM)');
set(gca,'FontSize',12);
hold on;
x = Nutrients1{:,3};
y = Nutrients1{:,6};
err = Nutrients1{:,7};
yyaxis right;
errorbar(x,y,err,'b');
ylim([0.08 1.13]);
ylabel('conc. (\muM)');
set(gca,'FontSize',12);

Iniciar sesión para comentar.

Categorías

Más información sobre Errorbars en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by