File: boxplot_demo3.py

package info (click to toggle)
matplotlib 1.1.1~rc2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 66,076 kB
  • sloc: python: 90,600; cpp: 69,891; objc: 5,231; ansic: 1,723; makefile: 171; sh: 7
file content (27 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy as np

np.random.seed(2)
inc = 0.1
e1 = np.random.uniform(0,1, size=(500,))
e2 = np.random.uniform(0,1, size=(500,))
e3 = np.random.uniform(0,1 + inc, size=(500,))
e4 = np.random.uniform(0,1 + 2*inc, size=(500,))

treatments = [e1,e2,e3,e4]

fig = plt.figure()
ax = fig.add_subplot(111)
pos = np.array(range(len(treatments)))+1
bp = ax.boxplot( treatments, sym='k+', patch_artist=True,
                 positions=pos, notch=1, bootstrap=5000 )
text_transform= mtransforms.blended_transform_factory(ax.transData,
                                                     ax.transAxes)
ax.set_xlabel('treatment')
ax.set_ylabel('response')
ax.set_ylim(-0.2, 1.4)
plt.setp(bp['whiskers'], color='k',  linestyle='-' )
plt.setp(bp['fliers'], markersize=3.0)
fig.subplots_adjust(right=0.99,top=0.99)
plt.show()