Wednesday, May 8, 2013

PL#4: Bar and error bar plot


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

import numpy as np
import matplotlib.pyplot as plt

N = 8
barheight = (25, 39, 60, 35, 27, 65, 8, 12)

ind = np.arange(N) # the x locations
rects1 = plt.bar(ind, barheight, width = 0.6, color='g')

plt.grid(True)


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

import numpy as np
import matplotlib.pyplot as plt

N = 8
barheight = (25, 39, 60, 35, 27, 65, 8, 12)

ind = np.arange(N) # the x locations
rects1 = plt.bar(ind, barheight, width = 1, color='g')

plt.grid(True)





#!/usr/bin/env python

# add error bar 
from __future__ import print_function

import numpy as np
import matplotlib.pyplot as plt

N = 8
barheight = (25, 39, 60, 35, 27, 65, 8, 12)
errbar = (6, 8, 3, 4, 8,4, 3, 8)
ind = np.arange(N) # the x locations
rects1 = plt.bar(ind, barheight, width = 0.6, color='g', yerr=errbar, error_kw=dict(elinewidth=3, ecolor='yellow'))

plt.grid(True)








No comments:

Post a Comment