exportgraphics function output has incorrect font and spacing between characters
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm exporting a figure of a plot using the exportgraphics function. For both vector .pdf and raster .png files, the sans serif LaTeX font is not shown correctly in both cases.
Snippet:
exportgraphics(fig, ...
'output.png', ...
'Resolution', 300)
exportgraphics(fig, ...
'output.pdf', ...
'ContentType', 'vector')
Where 'fig' is the figure object in question. Also, MATLAB shows the following warning:
% Error updating Text.
% Font cmss10 is not supported.
Below is a comparison of what I see in MATLAB and what the exported .png looks like.
MATLAB:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1505779/image.png)
PNG output:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1505784/image.png)
The vector output in PDF looks just like the PNG.
0 commentaires
Réponses (1)
Avni
le 19 Oct 2023
Hi Johann,
I understand that facing some problem while exporting the plotted graph with Sans Serif Latex font.
To achieve this, please refer to the following code as example:
fig = figure;
plot(magic(5));
xlabel("testing (X)", "FontName","SansSerif", "Interpreter","latex")
ylabel("testing (Y)", "FontName","SansSerif", "Interpreter","latex")
ax = gca;
exportgraphics(ax, 'output.png','Resolution', 300)
exportgraphics(ax,'output.pdf', 'ContentType', 'vector')
By following these steps, you should be able to export a figure with labels in sans serif LaTeX font in both JPG and PDF formats using “exportgraphics” function in MATLAB.
You can refer to these MATLAB documentations for more information:
I hope this helps.
3 commentaires
Voir également
Catégories
En savoir plus sur Printing and Saving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!