yyaxis plots results in exportgraphics being much slower than saveas (for vectorised PDF and SVG)

조회 수: 46 (최근 30일)
Since Matlab 2025(b?) custom fonts are finally embdedded when using saveas and exportgraphics to produce pdfs, and exportgraphics allows SVG exports. This allows a basic comparison of the performance.
  1. When using single yaxis plots no major difference were observed between saveas and exportgraphics.
  2. When using yyaxis in plots exportgraphics is much slower than saveas. A factor 2 or more.
Tests were performed locally in Windows 11. I do see some potentially better multicore facilitation with saveas. Running the code here in the forum does not seem to replicate the differences.
Normally I would define axes positions and sizes for the subplots such that the layout and output margins are tightly controlled in the export with saveas. This would produce visual output close to identical between the export methods. This was not needed to produce the time difference so it is skipped in the example, which leads to some layout differences between the export methods.
Any ideas behind this?
% generate data
x = (0:0.0001:250)';
y = sin(x)+rand(length(x),1);
% plot
figNr = figure;
set(figNr,'units','centimeters')
%paper settings and figure paper size
set(figNr,'paperunits','centimeters','papersize',[20 21],'paperposition',[0 0 20 21])
%figure screen position and size
set(figNr,'units','centimeters','position',[10 10 20 21])
subplot(3,1,1)
yyaxis left
plot(x,y)
yyaxis right
plot(x,y+1*0.1*x)
subplot(3,1,2)
yyaxis left
plot(x,2.*y)
yyaxis right
plot(x,2.*y+0.12*x)
subplot(3,1,3)
plot(x,0.1.*y)
% set a non-default font to test embeddding:
% fontname(figNr,"Libertinus Sans")
% compare export methods
% this is only applicable in Matlab 2025b (and maybe 2025a),
% since custom fonts were not embedded by saveas in prior versions
tic
saveas(figNr,'a_test','svg')
saveas(figNr,'a_test','pdf')
saveas(figNr,'a1_test','svg')
saveas(figNr,'a1_test','pdf')
toc
% this is only applicable in Matlab 2025a and onwards since
% svg files can now by exported (and custom fonts embedded in pdf)
tic
exportgraphics(figNr,'b_test.svg','ContentType','vector')
exportgraphics(figNr,'b_test.pdf','ContentType','vector')
exportgraphics(figNr,'b1_test.svg','ContentType','vector')
exportgraphics(figNr,'b1_test.pdf','ContentType','vector')
toc
  댓글 수: 2
dpb
dpb 2025년 10월 16일 12:11
편집: dpb 2025년 10월 16일 12:46
Submit this to Mathworks as an official support request/bug at <Product Support Page> with your specific system timings and configuration.
You might try profiling and see where the time bottleneck is and compare actual file sizes generated.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품


릴리스

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by