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

2 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 30 Mär. 2020
Bearbeitet: Walter Roberson am 30 Mär. 2020
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 Kommentare
Peter Bäuerle
Peter Bäuerle am 30 Mär. 2020
How do I get rid of the white frame around the image by using saveas or print?
Peter Bäuerle
Peter Bäuerle am 30 Mär. 2020
Found a simple solution to extend the plot over the whole figure:
set(gca,'position',[0 0 1 1],'units','normalized')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Printing and Saving 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