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

2 Ansichten (letzte 30 Tage)
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 Kommentare
Glenn Bitar
Glenn Bitar am 15 Nov. 2018
I have edited the original question with a MWE and some files showing the difference.
ks905383
ks905383 am 26 Mär. 2019
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Bjorn Gustavsson
Bjorn Gustavsson am 26 Mär. 2019
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
  3 Kommentare
Bjorn Gustavsson
Bjorn Gustavsson am 27 Mär. 2019
That's "interesting" - I haven't had that problem, yet. I'll cling to my solution and hope I don't get your problem, and hope you refind the solution you've used before...
Glenn Bitar
Glenn Bitar am 27 Mär. 2019
I'm on R2018b now, and was able to reproduce the bug with the MWE provided in the original post. Using your solution fixes the problem for me in that case (with 20 vs 21 signals). Thank you very much.
MWE amended with your solution for future reference:
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', '-painters')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by