필터 지우기
필터 지우기

Export to SVG changes symbols on axes

조회 수: 19 (최근 30일)
Fabian
Fabian 2014년 12월 17일
편집: Frauke Gellersen 2021년 10월 29일
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