Wednesday, May 8, 2013

PL#6: Plot bar plot (error bar plot) with different width scaled to other variable


#!/usr/bin/env python
from __future__ import print_function

import numpy as np
import matplotlib.pyplot as plt

N = 8
barheight1 = (25, 39, 60, 35, 27, 5, 8, 12)
widthvar = (15, 29, 30, 15, 17, 25, 18, 8)
width = [x/float (max(widthvar)) for x in widthvar]

ind = np.arange(N) # the x locations
rects = plt.bar(ind, barheight1, width = width, color='g', yerr=berr1, error_kw=dict(elinewidth=2, ecolor='pink'))
plt.axis([-0.3, 8, -10, 70])
plt.grid(True)

# other labs
plt.ylabel('Ylab')
plt.title('My plot title')
plt.xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8') )




No comments:

Post a Comment