Figures with large amounts of data don't export properly to .eps

조회 수: 9 (최근 30일)
Glenn Bitar
Glenn Bitar 2018년 11월 14일
댓글: Victor 2025년 9월 3일 8:20
I don't view the accepted answer of combining a png export with the axis as a solution, it's rather a work-around.
EDIT: MWE for the issue.
clear
N_signals = 21;
N_datapoints = 5000;
A = rand(N_signals,N_datapoints)*2-1;
A = diag(fliplr(1:N_signals)) * A;
t = linspace(0,1,N_datapoints);
figure(1)
clf
plot(t,A)
print('eps_bug', '-depsc')
This code produces a rasterized and compressed image to eps_bug.eps when N_signals = 21, but a nice vectorized image when N_signals = 20 for me.
I have attached 2 pngs showing excerpts of the eps files in SumatraPDF. Also, the file sizes produced by the two variations differ wildly. The N_signals = 20 is 1.7 MB, while N_signals = 21 is 0.3 MB.
END EDIT
Do the people of MATLAB have a solution for this, i.e. a bug fix?
My matlab version:
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.2.0.538062 (R2017a)
MATLAB License Number: xxxxxxxx
Operating System: Microsoft Windows 10 Pro N Version 10.0 (Build 17134)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 9.2 (R2017a)
  댓글 수: 3
Glenn Bitar
Glenn Bitar 2018년 11월 15일
I have edited the original question with a MWE and some files showing the difference.
ks905383
ks905383 2019년 3월 26일
I have this problem from time to time as well (as right now) - and every time I forget how to solve it; though given how randomly it shows up, sometimes I feel that it may just randomly dissappear again as well... This mainly happens for me when exporting gridded plots/maps (using pcolorm fo example), and results in 3-4GB plots that crash MATLAB when exporting.
This doesn't happen all the time - in fact, most of the figures I print have similar characteristics - and I have no idea what's going on.

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

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2019년 3월 26일
The solution to avoid this arbitrary choise of output renderer is to explicitly select painters:
print('-depsc2','-painters',filename)
It is a bit of a mystery as to why matlab selects to use opengl or zbuffer, but in my experience it
works when one explicitly selects "painters" - provided the graph doesn't contain too complicated
3-D structures that confuses the painter.
HTH
  댓글 수: 5
Lingxiao Qin
Lingxiao Qin 2025년 3월 2일
I am using MATLAB R2023b and encountered the same issue when exporting a high-quality figure with many data points to a PDF file. This solution worked for me as well. However, I find it strange that specifying the 'painters' renderer via File → Export Setup → Rendering does not achieve the same effect.
Victor
Victor 2025년 9월 3일 8:20
Thanks this saved me, and can confirm that on 2024b File → Export Setup → Rendering does not achieve the same effect.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by