Save a figure with two plots
1 次查看(过去 30 天)
显示 更早的评论
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')
采纳的回答
Kevin Claytor
2012-7-11
Your code is just saving the current axes, you want;
hfig = figure;
hplot = plot(price,supply,price,demand)
saveas(hfig,'myplot','png')
2 个评论
Matt Kindig
2012-7-12
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!