Plotting data dengan menggunakan python 3.3.2
Surya Andika
1215031070
Kelas B
GRAFIK
SYNTAX
import matplotlib.pyplot as plt
hondaMeans = (331986,382635)
ind = np.arange(2)
width = 0.1
plt.subplot(111)
rects1 = plt.bar(ind, hondaMeans, width,
color='r',
error_kw=dict(elinewidth=5, ecolor='pink'))
yamahaMeans = (277686,206704)
rects2 = plt.bar(ind+width, yamahaMeans, width,
color='y',
error_kw=dict(elinewidth=5, ecolor='yellow'))
suzukiMeans = (47614,53337)
rects3 = plt.bar(ind+width+width, suzukiMeans, width,
color='b',
error_kw=dict(elinewidth=5, ecolor='yellow'))
kawasakiMeans = (8762,8553)
rects4 = plt.bar(ind+width+width+width, kawasakiMeans, width,
color='orange',
error_kw=dict(elinewidth=5, ecolor='yellow'))
tvsMeans = (1016,2000)
rects5 = plt.bar(ind+width+width+width+width, tvsMeans, width,
color='pink',
error_kw=dict(elinewidth=5, ecolor='yellow'))
kanzenMeans = (60,0)
rects6 = plt.bar(ind+width+width+width+width+width, kawasakiMeans, width,
color='brown',
error_kw=dict(elinewidth=5, ecolor='yellow'))
plt.ylabel('jumlah')
plt.title('Penjualan Motor bulan Januari pada tahun 2011-2012')
plt.xticks(ind+width, ('Januari 2011','Januari 2012') )
plt.legend( (rects1[0], rects2[0], rects3[0],rects4[0], rects5[0], rects6[0]), ('Honda','Yamaha','Suzuki','Kawasaki','TVS','Kanzen') )
def autolabel(rects):
for rect in rects:
height = rect.get_height()
plt.text(rect.get_x()+rect.get_width()/4., 1.01*height, '%d'%int(height),
ha='left', va='bottom')
autolabel(rects1)
autolabel(rects2)
autolabel(rects3)
autolabel(rects4)
autolabel(rects5)
autolabel(rects6)
plt.show()
SUMBAR DATA
0 komentar:
Posting Komentar