Jung-Hyun
Jung-Hyun

Reputation: 353

Boxplots in Matplotlib: fill markers in the boxes

I'd like to fill markers inside boxes as the following boxplot image.

I don't have idea how to implement this. I searched for it on the web. There are posts about filling colours in the boxes (http://matplotlib.org/examples/pylab_examples/boxplot_demo2.html) but it seems there are no posts about filling markers.

Boxplot

Upvotes: 2

Views: 1514

Answers (1)

DrV
DrV

Reputation: 23510

It should be relatively simple. I took the example and added one line (set_hatch) immediately after the creation of the polygon:

...
boxPolygon = Polygon(boxCoords, facecolor=boxColors[k])
boxPolygon.set_hatch('*')
ax1.add_patch(boxPolygon)
...

and removed the sample marker plot command. This is what I got:

enter image description here

For more information on patch.set_hatch, see this example.

Upvotes: 2

Related Questions