Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib: Change linewidth on all subplots

I'm plotting a grid of subplots (6x2) with matplotlib (version 1.3.1) and Python 2.7. I set up my figure and plot things in the subplots like this:

fig, axes = plt.subplots(ncols=6, nrows=2, 
                         sharex=True, sharey=True, figsize=(30,5))

axes[0,0].plot(x, y)
axes[1,5].plot(z, a)

etc.

My question is this: is there a way to change the line properties on all of these plots at once? I could manually specify axes[0,0].plot(x,y,'k',linewidth=2.0) on each of the axes, but I thought there must be a way to do it for all 12 plots at once.

Cheers.

like image 896
thosphor Avatar asked Jan 28 '15 11:01

thosphor


People also ask

How do you change linewidth in matplotlib?

Matplotlib allows you to adjust the line width of a graph plot using the linewidth attribute. If you want to make the line width of a graph plot thinner, then you can make linewidth less than 1, such as 0.5 or 0.25.

What is the default linewidth matplotlib?

Linewidth: By default the linewidth is 1. For graphs with multiple lines it becomes difficult to trace the lines with lighter colors.

What does the parameter linewidth of the plot () function control?

In the plot() method after declaring the linewidth parameter, you assign it to any number value you want to represent the desired width of your plot.


1 Answers

Try this:

import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2

This should dynamically change the default matplotlibrc configuration.

Edit: nevermind, already mentioned in the comments to your question.

like image 172
dudenr33 Avatar answered Oct 15 '22 09:10

dudenr33