Saving figure as a image
Mostrar comentarios más antiguos
I am saving my output figures as images. But when I run my matlab script from different computers, the figures look different. As in the labels and legends are different sizes, etc. I want the image outputs to be exactly the same no matter what computer I run it on, I do not want to have computer specific scripts.
I am not a graphics person, so I do not know what causes this. Whether it is the screen resolution, renderer, file type, options or what? I do not know where to start.
The code I am using to save figure is:
output_file = 'example_image.png'
saveas(figure1,fullfile(folderName, output_file));
which outputs the following image:

Help!!
9 comentarios
Adam Danz
el 12 de Abr. de 2021
If you're using r2020a or later, see exportgraphics
meghannmarie
el 12 de Abr. de 2021
Adam Danz
el 13 de Abr. de 2021
Could you attach the figure?
meghannmarie
el 13 de Abr. de 2021
Adam Danz
el 13 de Abr. de 2021
No, I'm asking about the figure file (.fig). If you save the figure and attach it we can more easily try some options with exportgraphics or other functions. After saving the fig, open it and make sure it appears correctly. Also, what Matlab release are you using?
meghannmarie
el 13 de Abr. de 2021
Editada: meghannmarie
el 13 de Abr. de 2021
Adam Danz
el 13 de Abr. de 2021
I'm losing track of the goal/question.
Is the question why do the figures appear differently between r2019a and r2021a or is the question how to export figure as pdf without changing the appearance?
Adam Danz
el 13 de Abr. de 2021
From the figure menu, when I select File > SaveAs > PDF the results look quite similar.

meghannmarie
el 13 de Abr. de 2021
Editada: meghannmarie
el 13 de Abr. de 2021
Respuesta aceptada
Más respuestas (1)
David Hill
el 1 de Abr. de 2021
0 votos
You might try figure2pdf in file exchange.
2 comentarios
meghannmarie
el 1 de Abr. de 2021
Adam Danz
el 13 de Abr. de 2021
meghannmarie's answer moved here as a comment
-----------------------------------------------------------------------------
The figure2pdf function does not work. The pictures still save differently on different machines.
Look at my attachments, one is saved on my laptop and one is saved on our hpc. They are different, but same exact script. I think it is something to do with resolution of screen, but how do I get around it?
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


