Borrar filtros
Borrar filtros

How to plot two plotyy plots in the same plot

4 visualizaciones (últimos 30 días)
Benjamin
Benjamin el 15 de Ag. de 2011
Respondida: Nir Dahan el 25 de Ag. de 2015
I am trying to plot four plots in the same figure. First i plot using plotyy. Then two graphs are created, each with a yaxis.
Now I want to plot another two plots. One using yaxis-1 and one using yaxis-2. How do i do this?
If I do
[ax,h1,h2] = plotyy(...)
hold on
plot(ax(1),...)
plot(ax(2),...)
i don't get all four plots.
Thanks :)
Ben
  1 comentario
Benjamin
Benjamin el 15 de Ag. de 2011
I mean:
[ax,h1,h2] = plotyy(...)
hold on
plot(ax(1),...)
plot(ax(2),...)

Iniciar sesión para comentar.

Respuesta aceptada

Paulo Silva
Paulo Silva el 15 de Ag. de 2011
[ax,h1,h2] = plotyy(...)
hold(ax(1))
plot(ax(1),...)
hold(ax(2))
plot(ax(2),...)
The problem was simple, hold on just holds the current axes and your plotyy makes two axes so only one is the current.
  2 comentarios
Benjamin
Benjamin el 15 de Ag. de 2011
Phenomenal, thanks!:)
Rajeev Yadav
Rajeev Yadav el 5 de Jun. de 2015
doesnt work

Iniciar sesión para comentar.

Más respuestas (2)

the cyclist
the cyclist el 15 de Ag. de 2011
figure
[hax12 line1 hline2] = plotyy(1:10,1:10,1:10,2:11)
set(hax12,'NextPlot','add')
plot(hax12(1),1:10,3:12)
plot(hax12(2),1:10,4:13)
  5 comentarios
Rajeev Yadav
Rajeev Yadav el 5 de Jun. de 2015
i tried this but it doesnt work in 2015a
Soroush
Soroush el 17 de Jul. de 2015
Thanks!

Iniciar sesión para comentar.


Nir Dahan
Nir Dahan el 25 de Ag. de 2015
try this one where all vectors are column, of size (N,1)
[ax,h1,h2]=plotyy([x,x,x,...],[y1,y2,y3,...],[X,X,X,...],[Y1,Y2,Y3,...])

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by