how to save a plot ?

I have two large data sets. Usually it takes a lot of time to save a plot on hard drive. I wonder how I can save a plot as jpeg file in a quick way. Usually it takes a lot of time to save a plot on hard drive. I apperciate your help.
saveas(gcf,'C:\plot.jpg')
delete(gcf)

댓글 수: 5

Hassan
Hassan 2011년 6월 19일
I think the problem is about just saving the data. I didnt use the saveas function and it was much faster.
Walter Roberson
Walter Roberson 2011년 6월 19일
saveas() requires rendering the plot; it is almost always faster to save() the plot data rather than rendering it.
Hassan
Hassan 2011년 6월 19일
you mean there's another function called save(). If so, I couldn't find it.
Walter Roberson
Walter Roberson 2011년 6월 19일
save() is the counterpart of load()
http://www.mathworks.com/help/techdoc/ref/save.html
It stores the data instead of the image, so whether it is useful to you depends on what you need to do afterwards.
Hassan
Hassan 2011년 6월 20일
I see, it's not the one I need then.

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

답변 (2개)

Jan
Jan 2011년 6월 19일

1 개 추천

I guess that it is not the saving, but the drawing of the plot, which consumes the most time. "delete(gcf)" means, that you create a new figure for each plot. This is much slower than using the same figure and only update the axes object, or even better: Keep the axes also and update just the children.
So please insert a DRAWNOW before the method for sving and use the PROFILEr to find the most time consuming lines.

댓글 수: 6

Hassan
Hassan 2011년 6월 19일
Thanks Jan. I used DRAWNOW before saveas() function in the code. it didn't make the code to excute faster. I also used profile (profile on -history) in the beginning of the code or more precise in the begining of the loop. it showed that saves, prin, graphics\private\render and harcopy functions take longer to execute, each of them takes 3 min to finish their job.
Jan
Jan 2011년 6월 19일
DRAWNOW cannot accelerate the processing, but it flushs all former drawing commands. Without DRAWNOW the update of the figure is done inside the procedure for saving, such that the profile gets wrong timings.
Can you post the results of the profiler or relevant parts of the code? What is "prin"?
Hassan
Hassan 2011년 6월 19일
sorry, it is 'print'. this is the profile summary:
Function Name Calls Total Time Self Time* Total Time Plot
(dark band = self time)
saveas 1 222.095 s 0.015 s
print 1 222.080 s 0.000 s
graphics\private\render 1 220.485 s 0.000 s
hardcopy 1 220.470 s 220.470 s
xlswrite 4 13.406 s -0.000 s
xlswrite>ExecuteWrite 4 12.329 s 12.283 s
Hassan
Hassan 2011년 6월 19일
actxserver 4 1.047 s 1.047 s
graphics\private\prepare 1 0.828 s 0.765 s
graphics\private\restorehg 1 0.719 s 0.687 s
graphics\private\restore 1 0.719 s 0.000 s
specgraph.scattergroup.refresh 2 0.500 s 0.500 s
...ph.scattergroup.schema>LdoDirtyAction 3 0.500 s 0.000 s
workspacefunc 8 0.108 s -0.000 s
workspacefunc>getStatObjectsJ 4 0.077 s 0.030 s
graphics\private\preparehg 1 0.063 s 0.000 s
scatter 1 0.047 s 0.016 s
graphics\private\fireprintbehavior 2 0.047 s 0.015 s
workspacefunc>getStatObjectJ 256 0.047 s -0.000 s
xlswrite>activate_sheet 4 0.046 s 0.046 s
hggetbehavior 364 0.032 s 0.032 s
workspacefunc>createComplexScalar 252 0.032 s 0.016 s
workspacefunc>num2complex 362 0.032 s 0.000 s
lsline 1 0.031 s 0.016 s
fileparts 12 0.031 s 0.031 s
workspacefunc>getShortValueObjectsJ 2 0.031 s 0.015 s
workspacefunc>getStatObjectM 256 0.031 s 0.000 s
workspacefunc>local_max 94 0.031 s 0.031 s
num2str 18 0.016 s 0.016 s
graphics\private\name 1 0.016 s 0.000 s
spa_sf 1 0.016 s 0.016 s
xlabel 4 0.016 s 0.016 s
findall 14 0.016 s 0.016 s
specgraph.scattergroup.scattergroup 1 0.016 s 0.016 s
kurtosis 2 0.016 s 0.016 s
graphics\private\restoreui 1 0.016 s 0.016 s
graphics\private\inputcheck 1 0.016 s 0.000 s
cell.strmatch 2 0.016 s 0.000 s
strmatch 2 0.016 s 0.016 s
gra...rivate\inputcheck>LocalCheckDevice 1 0.016 s 0.000 s
savtoner
Walter Roberson
Walter Roberson 2011년 6월 19일
So effectively the bulk of the time is being used in the built-in function toolbox/matlab/graphics/hardcopy which is being called by the plot renderer.
Hassan
Hassan 2011년 6월 20일
it take longer than it shows on profiler. I tried that and when I dont save the plot, it's much faster (although not quite fast).

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

Walter Roberson
Walter Roberson 2011년 6월 19일

0 개 추천

There is a possibility that Oliver's export_fig might be faster; it's worth a try.

댓글 수: 3

Hassan
Hassan 2011년 6월 19일
thanks Walter, but it takes about the same time to save the plot.
Walter Roberson
Walter Roberson 2011년 6월 19일
Hmm... what kind of scene elements do you use? If you do not have transparency, then _possibly_ changing the renderer property of the figure or the drawmode property of axes could help. Unfortunately I do not know how rendering is done for saving images, so these things might not make any difference.
Hassan
Hassan 2011년 6월 19일
sorry Walter, I didnt understand the meaning of scene elements, transprancy and renderer. but will have a look at them.

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

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

질문:

2011년 6월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by