将matlab图形另存为SVG的问题:SVG文件的轴长度不正确

时间:2019-02-07 15:10:35

标签: matlab svg plot

我在将Matlab图形保存为“ .svg”并随后在Inkscape中打开它时遇到问题。更准确地说,我需要两个子图才能达到特定的高度,即6厘米。在Matlab中,可以通过设置“位置”属性(并将单位设置为“厘米”)来完成此操作。所有这些都按预期工作,然后将图形导出为“ .svg”

问题是当我将图形导入到Inkscape中时,轴的长度接近于我设置的值,但不正确。即我将其设置为6厘米,在Inkscape中为6.28。这不是一个很大的错误,但是它完全破坏了首先定义它的目的。有任何想法吗?

我尝试以几种不同的方式导出图形,但结果始终相同。

figure('name','representative plasticity figure');
set(gcf,'Color','w','units','centimeters','position',...
[0 0 8.6 8.4],'PaperPositionMode','auto'); 
s1=subplot(2,1,1)
img = imagesc(magic(8)); hold on; 
set(gca, 'TickDir','out','FontSize',8.5,'LineWidth',0.59,'TickLength'...
,[0.03 0.00001]); 
c1 = colorbar; c1.Box = 'off';c1.TickDirection = 'out'; c1.FontSize = 8.5; 

ax1 = gca; ax1.Units = 'Centimeters';ax1.Position(3:4) = [3.427, 1.59]; 
box off;  % THIS IS THE SIZE I NEED BUT WHICH ISN'T PRINTED CORRECTLY

c1.Label.String = '[whatever]';
subplot(2,1,2)
p1=plot(randi(5,5),'r','LineWidth',0.64); hold on; 
box off; set(gca, 'TickDir','out','TickLength',...
[0.03 0.00001],'FontSize',8.5,'LineWidth',0.64);% legend('pre','post'); 
legend('boxoff');
ax2 = gca;ax2.Units = 'Centimeters';ax2.Position(3:4) = ax1.Position(3:4); 
xlabel ('whatever' ); ylabel('whatever');
print myplot -dsvg

图形的大小应为[3.427,1.59]以厘米为单位。在生成的Matlab图形中也是如此,但是在Inkscape中,它更像是3.6和1.7。

0 个答案:

没有答案