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

98 views (last 30 days)
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,

Accepted Answer

Zahra Yousefi Darani
Zahra Yousefi Darani on 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).

More Answers (1)

Varun Pant
Varun Pant on 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.

Categories

Find more on Labels and Annotations in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!