Dark or inverted color scheme

Is there a simple way to essentially invert the default plotting color
scheme so that the figure background is black and all text, ticks,
axes, axis labels, etc are white? I think what I want is to redefine
the RGB definitions of the standard color values 'b', 'y', 'k', etc so
that I can make a plot figure with a black background using the same
script as one for the normal white background.

A spent a little while googling and didn't find anything apart from
specifically setting different colors for every single plot element.
This would be tiresome.

Thanks in advance for any help,
Tom

Hi Tom,

You can create a custom matplotlibrc file [1] and use that for your plots. The settings you’d probably want to change are copied below. Note that not all plotting elements grab colors from rc parameters (unfortunately), so you may find that some functions will ignore these settings.

I think the simplest way (currently) to use the rc file is by putting it in the same directory as your plotting script (or wherever you’re executing your script). There’s a pending pull request [2] that adds the ability to load rc parameters from a file. Also, I maintain a small set of matplotlib convenience functions, including a stylesheet-like function. I added the rc parameters below as a new style and added an example to the documentation [3].

Hope that helps,

-Tony

[1] http://matplotlib.sourceforge.net/users/customizing.html

[2] https://github.com/matplotlib/matplotlib/pull/861

[3] http://tonysyu.github.com/mpltools/auto_examples/style/plot_dark_background.html

rc definitions for dark backgrounds

lines.color: white

patch.edgecolor: white

text.color: white

axes.facecolor: black

axes.edgecolor: white

axes.labelcolor: white

xtick.color: white

ytick.color: white

grid.color: white

figure.facecolor: black

figure.edgecolor: black

savefig.facecolor: black

savefig.edgecolor: black

···

On Fri, May 25, 2012 at 4:07 PM, Tom Aldcroft <aldcroft@…2475…> wrote:

Is there a simple way to essentially invert the default plotting color

scheme so that the figure background is black and all text, ticks,

axes, axis labels, etc are white? I think what I want is to redefine

the RGB definitions of the standard color values ‘b’, ‘y’, ‘k’, etc so

that I can make a plot figure with a black background using the same

script as one for the normal white background.

A spent a little while googling and didn’t find anything apart from

specifically setting different colors for every single plot element.

This would be tiresome.

Thanks in advance for any help,

Tom

Tony Yu:

rc definitions for dark backgrounds

lines.color: white

patch.edgecolor: white

don't forget to lighten the colours in axes.color_cycle (unless blue

on black, etc. suits you). This is used by plot and was one of my
numerous mistakes two days ago…

Jerzy Karczmarczuk

Indeed: blue on black is a fashion faux pas. :wink: Also the default color_cycle has black in it, so it should be changed, regardless of aesthetic considerations.

-Tony

···

On Friday, May 25, 2012, Jerzy Karczmarczuk wrote:

Tony Yu:

rc definitions for dark backgrounds

lines.color: white

patch.edgecolor: white

don't forget to lighten the colours in axes.color_cycle (unless blue

on black, etc. suits you). This is used by plot and was one of my
numerous mistakes two days ago…

Jerzy Karczmarczuk