import numpy as np import matplotlib.pyplot as plt #x = np.random.randn( 40, 10 ) #np.save('boxwhiskerdata', x ) x = np.load('boxwhiskerdata.npy') plt.xkcd() fig = plt.figure( figsize=(6,4) ) ax = fig.add_subplot( 1, 1, 1 ) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) ax.yaxis.set_ticks_position('left') ax.xaxis.set_ticks_position('bottom') ax.set_xlabel('Experiment') ax.set_ylabel('x') ax.set_ylim( -4.0, 4.0) ax.annotate('Median', xy=(3.9, 0.1), xycoords='data', xytext=(3.5, -2.5), textcoords='data', ha='right', arrowprops=dict(arrowstyle="->", relpos=(0.8,1.0), connectionstyle="angle3,angleA=-110,angleB=60") ) ax.annotate('1. quartile', xy=(5.8, -0.7), xycoords='data', xytext=(5.5, -3.5), textcoords='data', ha='right', arrowprops=dict(arrowstyle="->", relpos=(0.5,1.0), connectionstyle="angle3,angleA=30,angleB=70") ) ax.annotate('3. quartile', xy=(6.1, 0.6), xycoords='data', xytext=(6.5, 3.0), textcoords='data', ha='left', arrowprops=dict(arrowstyle="->", relpos=(0.0,0.0), connectionstyle="angle3,angleA=30,angleB=70") ) ax.annotate('minimum', xy=(6.1, -2.3), xycoords='data', xytext=(7.2, -3.3), textcoords='data', ha='left', arrowprops=dict(arrowstyle="->", relpos=(0.0,0.5), connectionstyle="angle3,angleA=10,angleB=100") ) ax.annotate('maximum', xy=(5.9, 2.8), xycoords='data', xytext=(4.9, 3.5), textcoords='data', ha='right', arrowprops=dict(arrowstyle="->", relpos=(1.0,0.5), connectionstyle="angle3,angleA=0,angleB=120") ) ax.boxplot( x, whis=100.0 ) plt.tight_layout() plt.savefig('boxwhisker.pdf') plt.show()