Borrar filtros
Borrar filtros

Save a figure with two plots

1 visualización (últimos 30 días)
Joseph Cullen
Joseph Cullen el 11 de Jul. de 2012
This seems like it should be very simple, but it doesn't work. I am plotting two lines in a figure, and want to save the figure as an image. However, the handle h is a vector and saveas doesn't like it. I can't find any help with this in the documentation. What am I missing?
h = plot(price,supply,price,demand)
saveas(h,'myplot','png')
  2 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 11 de Jul. de 2012
give us a real exemple
Joseph Cullen
Joseph Cullen el 12 de Jul. de 2012
This is the real example. It is a simple supply and demand plot.

Iniciar sesión para comentar.

Respuesta aceptada

Kevin Claytor
Kevin Claytor el 11 de Jul. de 2012
Your code is just saving the current axes, you want;
hfig = figure;
hplot = plot(price,supply,price,demand)
saveas(hfig,'myplot','png')
  2 comentarios
Joseph Cullen
Joseph Cullen el 12 de Jul. de 2012
Editada: Joseph Cullen el 12 de Jul. de 2012
Works! Thanks.
so the handles returned by plot are for each plot in the figure. hfig=figure; gives the handle to the whole figure.
Thats what I need to know.
Matt Kindig
Matt Kindig el 12 de Jul. de 2012
To be precise, the handles returned by plot are handles each of the line objects that make up the plot.
h = plot(price, supply, price, demand); %handles to 2 line objects
ha = get(h(1),'parent'); %handle to axes object
hf = get(ha,'parent'); %handle to figure object

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by