saving graphics as SVG changes predifined axes length

6 views (last 30 days)
Hi,
I have a problem with the correct saving of a Matlab figure as ".svg". More precisely, I need both subplots to be a specific height, i.e. 6cm. This can be done by setting the "Position" property (and setting the units to "centimeters"). This all works fine and I then export the figure as ".svg" (using the print command makes no difference).
The problem is that when I import the figure to inkscape the axes length is close to the value I set but not correct. I.e. I set it to 6 cm and it is 5.8 in inkscape. It is not much of an error, but it completely defeats the purpose of defining it in the first place. Any ideas?
Code example (including all the modifications I make to the plot, though probably not really relevant here):
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; % make colorbar
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); % AGAIN: THIS IS THE SIZE I NEED
xlabel ('whatever' ); ylabel('whatever');
print myplot -dsvg

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!