print() and saveas() produce svg files where text is stored as paths and not text - how to overcome?

97 vues (au cours des 30 derniers jours)
I am trying to export an .svg image of a matlab figure (see attachement) to convert it afterwards in Inkscape to a .pdf_tex file to include it in a nice way into my latex document. However when trying to export it with eiter print() or saveas() it always saves the labels as vector graphics paths and not as text. This makes it afterwards unfeasible to save the text of the image (labels, etc) as propper text for the latex file.
I have so far tried multiple things:
% Open the figure
openfig("25m_baseline_smoothing.fig");
h = gcf();
h.Renderer = "painters"; % To make sure I have a vector image
% Trial 1
print("25m_baseline_smoothing","-dsvg"); % Produces paths
% Trial 2
saveas(h, "25m_baseline_smoothing","svg"); % Produces paths, not text
Futher I also tried to save the figure with the menu in the figure dropdown menu (File > Save as...). I also tried to directly export the figure with matlab2tikz. This is not a solution either as matlab2tikz can't handle a tiled layout yet.
Is there a way to overcome this problem and export the labes directly as text to the .svg image?
Kind regards,

Réponse acceptée

Zahra Yousefi Darani
Zahra Yousefi Darani le 13 Jan 2023
I know where the problem comes from. When you use greek letter in the labels of axes, it is not compatible with the fonts of InkScape. The only solution that comes to my mind is that remove the greek letter in your code (labeling or text). Export your figure to .svg then open it in InkScape. After opening, apply your editions, then copy the greek letters as object path, from the figure that you have and is not text-recognnizable, then paste it to the current figure (text-recognizable).
  1 commentaire
Daniel
Daniel le 28 Juil 2023
You star! This is the answer to something I've been banging my head against the wall about! Thank you!

Connectez-vous pour commenter.

Plus de réponses (1)

Varun Pant
Varun Pant le 25 Sep 2024
I faced this problem, whenever I was using LATEX or TEX in axes labels and legends. The workaround I found was to use the greek symbols directly, and for more complicated symbols, as Zahra said, copy-paste them from somehwhere else.
Also, a sincere suggesttion, learn to use GNU plot. Its far easy and superior in its working.

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by