Going by the this example, http://matplotlib.org/examples/pylab_examples/barchart_demo.html
I wanted to generated the dynamic bar chart.so far I have following script.
import sys
import matplotlib.pyplot as plt
import numpy as np
groups = int(sys.argv[1])
subgroup = int(sys.argv[2])
fig, ax = plt.subplots()
index = np.arange(groups)
print index
bar_width = 1.0 / (subgroup + 1)
print bar_width
mainlist = []
for x in range(0, groups):
#print x
templist = []
for num in range(0, subgroup):
templist.append(num+1)
#print templist
mainlist.append(templist)
print mainlist
for cnt in range(0,subgroup):
plt.bar(index + (bar_width * cnt), mainlist[cnt], bar_width)
plt.savefig('odd_bar_chart.png')
This works fine when i pass same values for groups and subgroup,
> odd_bar_chart.py 3 3
> odd_bar_chart.py 2 2
but if i pass different values like this,
odd_bar_chart.py 3 2 odd_bar_chart.py 2 3
it gives following error AssertionError: incompatible sizes: argument 'height' must be length {first argument} or scalar
Now I dont know hw height comes in picture ? can anybody tell me whats wrong here ?
mainlist[cnt]has the length ofsubgroupwhileindexhas the length ofgroup. You cant plot like that if they have different lengths.