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

42 visualizaciones (últimos 30 días)
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 comentarios
dpb
dpb el 16 de Oct. de 2025 a las 12:11
Editada: dpb el 16 de Oct. de 2025 a las 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Productos


Versión

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by