Transparent figure Matlab 2020

441 Ansichten (letzte 30 Tage)
Jose Sosa Lopez
Jose Sosa Lopez am 8 Jul. 2020
Beantwortet: Richard Quist am 30 Mär. 2022
How to copy a figure with transparent background?

Akzeptierte Antwort

Jose Sosa Lopez
Jose Sosa Lopez am 8 Jul. 2020
If the graph is in figure 1, put in the command window of matlab:
figure (1)
set(gcf, 'color', 'none');
set(gca, 'color', 'none');
Then go to the figure, edit----> copy figure, and you can paste wherever you want, it will be with transparent background.

Weitere Antworten (1)

Richard Quist
Richard Quist am 30 Mär. 2022
If you want to do this programmatically and have MATLAB version R2020a or later you can use the copygraphics function with the BackgroundColor and ContentType parameters, without having to change the figure or axes color properties:
copygraphics(gcf, 'BackgroundColor', 'none', 'ContentType', 'vector');
In this case, I specified 'ContentType', 'vector' to ensure that the output is "true" vector (fully scalable) and isn't copied as a raster/bitmap image. If hadn't specified that MATLAB would look at the figure contents and decide what format to copy to the clipboard.
In earlier versions of MATLAB you would have to change the figure and axes colors and use the print function for this and specify the '-painters' flag to ensure the output is true vector:
set(gcf, 'color', 'none');
set(gca, 'color', 'none');
print(gcf, '-dmeta', '-painters');

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by