Saving figure with large number of data points.

4 ビュー (過去 30 日間)
mashtine
mashtine 2015 年 1 月 19 日
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!!

採用された回答

Chris Barnhart
Chris Barnhart 2015 年 1 月 19 日
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.
  1 件のコメント
mashtine
mashtine 2015 年 1 月 20 日
Thank you Chris!

サインインしてコメントする。

その他の回答 (1 件)

Shyamprasad Natarajan Raja
Shyamprasad Natarajan Raja 2023 年 9 月 20 日
export_fig() is very useful for this purpose.

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by