How can I save a figure to jpg and keep the legend background 'black'?

5 Ansichten (letzte 30 Tage)
Konstantin Sieler
Konstantin Sieler am 24 Okt. 2018
Bearbeitet: hooman arad am 10 Feb. 2023
My goal is to save a figure with a legend with a BLACK background and white text in jpg format.
The open figure and even the saved figure (as '.fig') and even saving the figure manually to another file format result in what I need (black legend background with white text).
Only when I try to automatically save in other file formats using saveas() with the formats 'jpg','tif','png' the figure is always saved with a WHITE legend background.
For an image displayed in a figure I tried:
iAmLegend = legend({'\color{black} myTitle'},'FontSize',30); % set legend text white
set(iAmLegend,'color','k'); % set legend background black
output_FileName = strcat(myCurrentWorkingDir, '/', 'myFileName.tif'); % set file path to save to
saveas(figureHandle, output_FileName,'tif'); % does not save BLACK legend background
I am grateful for any advice! Thank you!
  3 Kommentare
Konstantin Sieler
Konstantin Sieler am 25 Okt. 2018
thanks a lot this solved my problem!!!
hooman arad
hooman arad am 10 Feb. 2023
Bearbeitet: hooman arad am 10 Feb. 2023
check this
https://de.mathworks.com/matlabcentral/answers/425874-how-can-i-save-a-figure-to-jpg-and-keep-the-legend-background-black

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by