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

3 visualizaciones (últimos 30 días)
Pul
Pul el 13 de Sept. de 2024
Editada: DGM el 14 de Sept. de 2024
Display a geographic globe in a figure created using the uifigure function.
uif = uifigure;
g = geoglobe(uif);

Respuestas (1)

DGM
DGM el 13 de Sept. de 2024
Editada: DGM el 14 de Sept. de 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 comentarios
Walter Roberson
Walter Roberson el 14 de Sept. de 2024
saveas() supports uifigure starting from R2024a.
DGM
DGM el 14 de Sept. de 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.

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by