|
From: Tony Yu <ts...@gm...> - 2012-05-25 21:23:34
|
On Fri, May 25, 2012 at 4:07 PM, Tom Aldcroft <ald...@he... > 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 > > 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 |