Export to SVG changes symbols on axes

19 次查看(过去 30 天)
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.

采纳的回答

Richard
Richard 2020-12-29
编辑:Richard 2020-12-29
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 个评论
Frauke Gellersen
Frauke Gellersen 2021-10-29
编辑:Frauke Gellersen 2021-10-29
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!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by