Jumat, 14 Juni 2013

Tugas Kuliah Probabilitas dan Statistika

Plotting Data Menggunakan Pemrograman Python

Nama : Dika Fauzia
NPM : 1215031022
Kelas : B

Software yang digunakan :
Python 3.3.2

Data yang digunakan :



import numpy as np
import matplotlib.pyplot as plt

N = 13
produksiMeans = (77.040, 92.540, 103.329, 114.278, 132.352, 152.722, 193.761, 216.946, 240.249, 256.181, 275.164, 290.000, 386.000)

ind = np.arange(N)  # the x locations for the groups
width = 0.3       # the width of the bars

plt.subplot(111)
rects1 = plt.bar(ind, produksiMeans, width,
                    color='b',
                    error_kw=dict(elinewidth=20, ecolor='red'))

eksporMeans = (58.460, 65.281, 74.177, 85.680, 93.758, 110.789, 143.632, 163.000, 191.430, 198.366, 208.000, 209.100, 304.000)

rects2 = plt.bar(ind+width, eksporMeans, width,
                    color='green',
                    error_kw=dict(elinewidth=20, ecolor='red'))

konsumsiMeans = (18.579, 27.259, 29.151, 28.596, 36.081, 41.350, 48.995, 61.470, 48.926, 55.790, 67.000, 65.000, 67.300)

rects3 = plt.bar(ind+width+width, konsumsiMeans, width,
                    color='yellow',
                    error_kw=dict(elinewidth=20, ecolor='red'))
# add some
plt.ylabel('Jumlah (ribu ton)')
plt.title('Produksi, Ekspor dan Konsumsi Batubara 2000-2012')
plt.xticks(ind+width, ('2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009','2010','2011','2012') )

plt.legend( (rects1[0], rects2[0], rects3[0]), ('Produksi', 'Ekspor', 'Konsumsi'))

def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        plt.text(rect.get_x()+rect.get_width()/10., 1.01*height, '%d'%int(height),
                ha='left', va='bottom')
       
autolabel(rects1)
autolabel(rects2)
autolabel(rects3)

plt.grid()
plt.show()



Hasil tampilan gambar :


Data di atas merupakan data produksi, ekspor, dan konsumsi batubara (dalam jumlah ribuan ton) di Indonesia dari tahun 2000-2012.

0 komentar:

Posting Komentar

 
My Little Blog Blogger Template by Ipietoon Blogger Template