Saving figure with large number of data points.

7 Ansichten (letzte 30 Tage)
mashtine
mashtine am 19 Jan. 2015
Hi everyone,
I have a figure with 6 scatter subplots on it, each with a large number of data points on them (unfortunately, I need to show all to capture outliers). The obviously consumes a lot of memory and the situation only worsens when saving using the following:
print -dpdf -r300 example.pdf;
Not only does it take extremely long but when I am finished the pdf is cut oddly and does not match the matlab figure. I setup my figure size with the following:
figure
h1=gcf;
set(h1,'PaperOrientation','portrait');
set(h1,'PaperPosition', [1 1 28 19]);
set(0,'defaultfigurecolor',[1 1 1])
I know matlab is doing some compression in the background but is there a way to make this save more efficient as well as in the correct orientation? I do not like the quality of export_fig but if it is the best option then I have no choice. It is also equally slow.
Thanks!!

Akzeptierte Antwort

Chris Barnhart
Chris Barnhart am 19 Jan. 2015
Try using saveas to save the figure as an image.
These formats would contain one 'int' per pixel, even if many data points were plotted there.
I prefer PNG as JPG could contain artifacts.
Plotting with a marker '.'
>> numpts=1e5; iii=1:numpts; plot( sin(3*pi*iii/numpts)+rand(size(iii)),'.') >> saveas(gcf,'t1.png','png'); saveas(gcf,'t1.pdf','pdf')
t1.pdf ~= 1.5Mb t1.png = 86k
Plotting with lines - the PDF is able to compress some how. t1.pdf = 109k t1.png = 27k
Also, I recall that with older matlabs, the PNG resolution was greater if figure was large on the screen. With 2014b doesn't seem to be that way.

Weitere Antworten (1)

Shyamprasad Natarajan Raja
Shyamprasad Natarajan Raja am 20 Sep. 2023
export_fig() is very useful for this purpose.

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by