How can I save a figure (in jpeg and pdf) from this code?

3 次查看(过去 30 天)
Display a geographic globe in a figure created using the uifigure function.
uif = uifigure;
g = geoglobe(uif);

回答(1 个)

DGM
DGM 2024-9-13
编辑:DGM 2024-9-14
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 个评论
DGM
DGM 2024-9-14
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.

请先登录,再进行评论。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by