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
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