How to set the alpha value for matplotlib plots globally
Unfortunately, based on their How to entry:
If you need all the figure elements to be transparent, there is currently no global alpha setting, but you can set the alpha channel on individual elements.
So, via matplotlib there's currently no way to do this.
What I usually do for global values is define an external configuration file, define values and import them to the appropriate scripts.
# Parameters: # matplotlib alpha ALPHA = .6
import conf.py as CONF plot(x,y1, alpha=CONF.ALPHA) plot(x,y2, alpha=CONF.ALPHA)
This usually helps in keeping configuration separated and easy to update.
Answering my own question with help of the matplotlib team the following code will do the job by changeing the alpha value of the line colors globally:
alpha = 0.6 to_rgba = matplotlib.colors.ColorConverter().to_rgba for i, col in enumerate(plt.rcParams['axes.color_cycle']): plt.rcParams['axes.color_cycle'][i] = to_rgba(col, alpha)
Note: In matplotlib 1.5
color_cycle will be deprecated and replaced by
The ability the set the alpha value over the rcParams has also been added to the wishlist for Version 2.1