首页 > 解决方案 > 将 matlab 图形保存为 SVG 的问题:SVG 文件的轴长度不正确

问题描述

我在将 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。

标签: matlabsvgplot

解决方案


推荐阅读