Filter löschen
Filter löschen

Export to SVG changes symbols on axes

19 Ansichten (letzte 30 Tage)
Fabian
Fabian am 17 Dez. 2014
Bearbeitet: Frauke Gellersen am 29 Okt. 2021
Greetings MATLAB community,
while experimenting with figure exports, I found that, whenever I have a plot that has an exponential scaling factor attached to the axis and export it to SVG it will change the "x" symbol into a "#" symbol. The example is very easy:
plot(1e6*rand(10), 'o')
print(gcf, 'test', '-dsvg')
The plot directly exported to png (left) is fine, but exported to svg and then to png (right) is not:
I am, of course, aware that this problem could be avoided by exporting to a different format of by changing the tick labels. This question is aimed at understanding why this is happening, if it is intended and I am just doing something wrong or if it is indeed a bug.
I am grateful for any insights and hope everyone has a nice day.
Best regards, Fabian.

Akzeptierte Antwort

Richard
Richard am 29 Dez. 2020
Bearbeitet: Richard am 29 Dez. 2020
Hello Fabian, its almost 7 years later, but I have found solution. For some odd reason, if you change property of axes 'FontName' to different font type (Palatino linotype, Times new roman ...), the 'x' in exponent is showing properly. I don't know why tho. If you use multiple axes (subplot, axes, zoom ...), or mix them with graphical objects (text) with different Font types, it will also lead to wrongly generated '#' instead of 'x'.
This code outputs svg file without problem (tested on Matlab R2018a):
f=figure;
ax=gca;
plot(ax,1e6*rand(10), 'o');
set(ax,'FontName','Palatino linotype');
saveas(f, 'test', 'svg');
EDIT: If you list present system fonts by function:
d=listfonts
the fonts like Times New Roman, are written with capital letters, if you use them in that way in set of property 'FontName', it won't work, and the exponent will show '#'. But if you write them in lowercase , it works even with helvetica, so this is problem of font selection by Matlab. Hope it will help others.
  1 Kommentar
Frauke Gellersen
Frauke Gellersen am 29 Okt. 2021
Bearbeitet: Frauke Gellersen am 29 Okt. 2021
I just faced the same issue and could confirm the behaviour described here.
However, I also noticed that the generated svg changes.
  • With 'Helvetica' I have the x to # problem.
  • With 'helvetica' the x remains an x, but it is not a Text in Inkscape. It turns into a path.
That looks the same of course, but editing the text in Inkscape becomes difficult and if you import into LaTeX there will be no syntax recognition!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by