Exporting plot as .png from GUI with multiple axes
Afficher commentaires plus anciens
Hi,
I'm writing a GUI which continuously updates a set of plots within a figure (there are three axes showing, with their separate plots, all within that one figure). What I want to do is to export one of those plots as a png file. My problem is that I can't seem to do that correctly. I've tried a couple of things:
Using imwrite:
axes(myAxes);
dataPlot = imagesc(data);
dataFrame = getframe(myAxes);
[im,imMap] = frame2im(dataFrame);
imwrite(im,'fileNameHere');
The problem is that if I'm running the GUI in the background, it saves images of whatever's in the foreground, and not the actual plot that I want.
Using print:
*Plotting like above*
print('-dpng','fileNameHere');
But (I think, at least) that works only for entire figures, so it stores the entire GUI frame, which is more than what I need (and it looks more confusing too as an image).
One option, of course, is to create a temporary figure, plot it there and use print, but that slows the processing down a little, and looks really un-cool and un-swift, so I'd prefer to avoid that method.
I've noticed export_fig on File Exchange (which certainly looks like it could do the trick), but I was hoping there would be a simple built-in way of doing this. Is there one? (Pardon my noob-iness, I'm fairly new to Matlab)
Thanks for any help!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!