Box box face

I would like to do something like this (using matplotlib): enter image description here

(from Colorfill Box in R-crane with lines, dots or the like )

Did I see some information about hatch (ing)? But I really can't do heads or tails on how to use this.

I am also interested in how to change parameters, such as possible boxprop dict attributes used in plt.boxplot (..., boxprops = boxpropsdict). Is it possible to have a list of all possible attributes for this?

+4
source share
1 answer

An important aspect is patch_artist=Truecall setup boxplot.

import numpy as np
import matplotlib.pyplot as plt

# fake up some data
spread= np.random.rand(50) * 100
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * -100
data = np.concatenate((spread, center, flier_high, flier_low), 0)

# basic plot
bp = plt.boxplot(data, patch_artist=True)

for box in bp['boxes']:
    # change outline color
    box.set(color='red', linewidth=2)
    # change fill color
    box.set(facecolor = 'green' )
    # change hatch
    box.set(hatch = '/')

plt.show()

boxplot. patch_artist=True. , :

AttributeError: 'Line2D' 'set_facecolor'

boxplot demo 2 , . patch_artist.
. hatch. :

enter image description here

+8

All Articles