How can I save a figure (in jpeg and pdf) from this code?
2 views (last 30 days)
Show older comments
Display a geographic globe in a figure created using the uifigure function.
uif = uifigure;
g = geoglobe(uif);
0 Comments
Answers (1)
DGM
on 13 Sep 2024
Edited: DGM
on 14 Sep 2024
At least as of R2019b, saveas() and print() do not accept uifigure handles. The documentation suggests that's still the case, but my network connection is too crappy to open MATLAB online to verify that.
Documentation suggests that exportgraphics() should accept uifigure handles, but again, I cannot test that. It should support PDF outputs as well. Depending on what you're doing, maybe exportapp() is appropriate.
As always, using JPG for anything is usually a completely bad idea. For synthetic graphics with hard edges and flat coloring, JPG will produce a visually conspicuous degradation of image quality, and the file size will typically be larger than a PNG. Unless you understand what compromises come with a 70% 4:2:0 JPG, don't use JPG.
2 Comments
DGM
on 14 Sep 2024
Is that documented anywhere? Webdocs doesn't mention uifigure, and the closest relevant notes in RN is about removing support for UI elements in an undisclosed future release. From R2022b and R2023b:
These functions and menu items will no longer support printing or exporting UI components in a future release:
• The print function
• The saveas function
So they're going to remove support for saving uifigures containing buttons and stuff using these tools -- but as far as I know, they don't support uifigures anyway. What am I missing?
I'd test this, but again, I can't even get MATLAB online to load.
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!