Pandas x-axis box installation

I want to create a box of data collected from four different sites over the past twenty years (i.e. there will be 20y data on each site). The figure will display 80 boxes. To make the figure legible, I want each box offset and different fields for each site. This will give a repeated series of mailboxes (for example, mailboxes for sites1, site2, site3, site3, site1, site2, site3, ...). Creating a boxplot is not a problem; box bias seems to be a problem. eg.

import numpy as np
import pandas as pd
from pylab import *

first  = pd.DataFrame(np.random.rand(10,5),columns=np.arange(0,5))
second = pd.DataFrame(np.random.rand(10,5),columns=np.arange(5,10))

fig = figure( figsize=(9,6.5) )
ax  = fig.add_subplot(111)

box1 = first.boxplot(ax=ax,notch=False,widths=0.20,sym='',rot=-45)
setp(box1['caps'],color='r',linewidth=2)
setp(box1['boxes'],color='r',linewidth=2)
setp(box1['medians'],color='r',linewidth=2)
setp(box1['whiskers'],color='r',linewidth=2,linestyle='-')

box2 = second.boxplot(ax=ax,notch=False,widths=0.20,sym='',rot=-45)
setp(box2['caps'],color='k',linewidth=2)
setp(box2['boxes'],color='k',linewidth=2)
setp(box2['medians'],color='k',linewidth=2)
setp(box2['whiskers'],color='k',linewidth=2,linestyle='-')

Initially, I was hoping Pandas would index the x axis by column name, but Pandas seems to index the x axis according to the position of the column, which is disappointing. Can anyone recommend a method for moving boxes so that they do not lie on top of each other?

+3
1

:

box1 = first.boxplot(ax=ax,notch=False,widths=0.20,sym='',rot=-45, positions=np.arange(0.0,4.0,1.0))
box2 = second.boxplot(ax=ax,notch=False,widths=0.20,sym='',rot=-45, positions=np.arange(0.3,4.3,1.0))

, ( ):

disp = 0.15
for k in box1.keys():
    for line1,line2 in zip(box1[k],box2[k]):
        setp(line1,xdata=getp(line1,'xdata') - disp)
        setp(line2,xdata=getp(line2,'xdata') + disp)
+3

All Articles