Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
printing unwanted black background

Subject: printing unwanted black background

From: Sasan

Date: 29 Oct, 2011 03:37:15

Message: 1 of 5

Whenever I try to print a figure the output (jpeg, png) always has a black background, even when I set a white or clear background. My figures utilize the pcolor, surf, and/or slice functions. If anyone has encountered such issues and has found a solution, please share.

Subject: printing unwanted black background

From: Pavelo

Date: 20 Jul, 2012 14:09:20

Message: 2 of 5

"Sasan " <markjohnson@yahoo.com> wrote in message <j8fsdb$qo5$1@newscl01ah.mathworks.com>...
> Whenever I try to print a figure the output (jpeg, png) always has a black background, even when I set a white or clear background. My figures utilize the pcolor, surf, and/or slice functions. If anyone has encountered such issues and has found a solution, please share.

I'm having the same problem, and this unanswered question is the only mention of anyone else having it that i found. I'm sort of starting to think that this could be a rare bug.

At any rate, i have the same problem. I'm trying to save a surf plot and it comes out with black background, which also makes all the axis labels unreadable. I have tried various file formats. I have tried print and saveas commands. I have tried setting different background colors and turning inverthardcopy off and on. All to no avail.

If anyone had encountered something like this and had successfully fixed it, your help would be most appreciated.

Subject: printing unwanted black background

From: Pavelo

Date: 20 Jul, 2012 18:43:13

Message: 3 of 5

"Pavelo" wrote in message <juboqg$ca7$1@newscl01ah.mathworks.com>...
> "Sasan " <markjohnson@yahoo.com> wrote in message <j8fsdb$qo5$1@newscl01ah.mathworks.com>...
> > Whenever I try to print a figure the output (jpeg, png) always has a black background, even when I set a white or clear background. My figures utilize the pcolor, surf, and/or slice functions. If anyone has encountered such issues and has found a solution, please share.
>


So i played around a bit and here's what i figured out:

I get black background (that can't be corrected in an way that i've tried) when i save a pcolor, mesh, or surf image that has interpolated shading (shading interp). There is no problem for flat or faceted shading.

No idea why this is happening of if there is a way to fix it, but there you have it.

Subject: printing unwanted black background

From: Pavelo

Date: 20 Jul, 2012 20:53:17

Message: 4 of 5

So the above "solution" comes and goes: even with other shading setting it sometimes inexplicably saves the image with a black background. Interestingly enough, it seems to change depending on which 2D array i plot using surf. So i'm stumped. Seems very much like a bug, but i think i found a work around.

If you go to the image's "Copy Options" and in the "Figure Background Color" you select "Use Figure Color" then it seems to keep the color that you set yourself (default = grey).

Subject: printing unwanted black background

From: Henry

Date: 10 Jun, 2014 13:00:18

Message: 5 of 5

"Sasan " <markjohnson@yahoo.com> wrote in message <j8fsdb$qo5$1@newscl01ah.mathworks.com>...
> Whenever I try to print a figure the output (jpeg, png) always has a black background, even when I set a white or clear background. My figures utilize the pcolor, surf, and/or slice functions. If anyone has encountered such issues and has found a solution, please share.


So I have had this problem when every figure i exported using the openGL renderer has a black background which i did not want. I searched through the internet for a solution but never came across an answer. I thought I would post on here in case anyone else comes across this thread.

It appears that a setting has been unwillingly changed (although I dont know which one). My solution was to find the preferences directory by typing prefdir into the command line.

prefdir

Close matlab

Delete this folder

Re-open matlab.

The folder is recreated but not previous settings or history is used by matlab. It is quite annoying but it solved the issue with always having the black background with exported figures

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us