Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib border width

I use matplotlib 0.99.

I am not able to change width of border of subplot, how can I do it?

Code is as follows:

fig = plt.figure(figsize = (4.1, 2.2)) ax = fig.add_subplot(111)  ax.patch.set_ linewidth(0.1)  ax.get_frame().set_linewidth(0.1)  

The last two lines do not work, but the following works fine:

legend.get_frame().set_ linewidth(0.1) 
like image 260
aaa Avatar asked Oct 28 '09 19:10

aaa


People also ask

What is Matplotlib width?

The line width simply helps to give a unique description or visual to a particular data set in a plot. The default value for the line width of a plot in Matplotlib is 1 . However, you can change this size to any size of your choice.

How do I resize a plot in Matplotlib?

Set the Height and Width of a Figure in Matplotlib Instead of the figsize argument, we can also set the height and width of a figure. These can be done either via the set() function with the figheight and figwidth argument, or via the set_figheight() and set_figwidth() functions.

What is figure size in Matplotlib?

Syntax of matplotlib. It is an optional attribute, by default the figure has the dimensions as (6.4, 4.8). This is a standard plot where the attribute is not mentioned in the function. Normally each unit inch is of 80 x 80 pixels.


2 Answers

You want to adjust the border line size? You need to use ax.spines[side].set_linewidth(size).

So something like:

[i.set_linewidth(0.1) for i in ax.spines.itervalues()] 
like image 196
Mark Avatar answered Sep 25 '22 08:09

Mark


Maybe this is what you are looking for?

import matplotlib as mpl

mpl.rcParams['axes.linewidth'] = 0.1 #set the value globally

like image 32
weiqure Avatar answered Sep 26 '22 08:09

weiqure