Making a complex plot more efficient: is it possible to directly transform a subplot in a image?

조회 수: 2 (최근 30일)
Dear Matlab Community,
I have a plot with several subplot and different gui elements, some of them are initially hidden (depending on the user inputs). Well, this gui is rather slow. However, the user only has to interact with two of them and the other (likes a big surface plot) is static. Thus, I saved those static plots to png-images and import than as image to the gui, which accelerates the performance a lot.
So far I use a code like that
fig = figure( 'visible', 'off'); % plot in a separate figure to export the image
% my plotting options
tempF= getframe(fig); % save the image without white frame
img = tempF.cdata; % save the image without white frame
imwrite(img, 'tempFile.png'); % save the image without white frame
delete(fig); % delete the separate figure
TargetPlot=subplot('position',[0.05, 0.06, 0.8, 0.2]);
TargetPlot=image( imread('tempFile.png') ); % import the image
I’m wondering if there is a way instead of plotting (exportgraphics is not part of my version) the figure to directly transform it to an image?
All ideas to optimize that are welcome.
Thanks,
Peter

채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 30일
편집: Walter Roberson 2020년 3월 30일
I’m wondering if there is a way instead of plotting (exportgraphics is not part of my version) the figure to directly transform it to an image?
No. Before R2020a, all of the supported ways of exporting graphics involve using the rendering engine to create images of the plot -- though exporting to PDF could at least separate out the text.
Before R2020a, none of the supported ways of exporting graphics supported exporting as vector or as Microsoft meta-graphics. The closest to that is that the File Exchange contribution export_fig supports saving to svg . (Though possibly print() supported rendering to clipboard, I would have to recheck that point.)
As of R2020a, copygraphics() supports saving to clipboard, and exportgraphics supports writing to pdf in vector form.
  댓글 수: 4
Peter Bäuerle
Peter Bäuerle 2020년 3월 30일
How do I get rid of the white frame around the image by using saveas or print?
Peter Bäuerle
Peter Bäuerle 2020년 3월 30일
Found a simple solution to extend the plot over the whole figure:
set(gca,'position',[0 0 1 1],'units','normalized')

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by