MEMBUAT TAMPILAN GRAFIK DATA STATISTIK
MENGGUNAKAN BAHASA PEMROGRAMAN PYTHON
Oleh :
AHMAD LIFANI
1215031006
PERBANDINGAN HARGA EMAS DAN PERAK DARI TAHUN 1840 - 2011
Tampilan Grafik :
Sintak Program :
import numpy as np
import matplotlib.pyplot as plt
N = 13
perakMeans = (1.29,0.64,0.65,0.34,0.91,1.63,16.39,4.06,4.95,7.31,14.67,20.19,40.17)
ind = np.arange(N)
width = 0.3
plt.subplot(111)
rects1 = plt.bar(ind, perakMeans, width, color='r')
emasMeans = (20,20,20,33,35,35,612,383,279,444,972,1225,1469)
rects2 = plt.bar(ind+width, emasMeans, width, color='g')
plt.ylabel('HARGA (US$)')
plt.title('Perbandingan Harga Emas dan Perak dunia pada tahun 1840-2011')
plt.xticks(ind+width, ('1840', '1900', '1920', '1940', '1940', '1960', '1970', '1980', '1990', '2000', '2005', '2009', '2010', '2011'))
plt.legend((rects1[0], rects2[0]), ('perak', 'emas'))
def autolabel(rects):
for rect in rects:
height = rect.get_height()
plt.text(rect.get_x()+rect.get_width()-0.5 , 1*height, '%d'%int(height), ha='left', va='bottom')
autolabel(rects1)
autolabel(rects2)
plt.show()
Sumber data statistik :
http://odnv.co.id/rasio-harga-emas-dan-perak-dari-waktu-ke-waktu
import matplotlib.pyplot as plt
N = 13
perakMeans = (1.29,0.64,0.65,0.34,0.91,1.63,16.39,4.06,4.95,7.31,14.67,20.19,40.17)
ind = np.arange(N)
width = 0.3
plt.subplot(111)
rects1 = plt.bar(ind, perakMeans, width, color='r')
emasMeans = (20,20,20,33,35,35,612,383,279,444,972,1225,1469)
rects2 = plt.bar(ind+width, emasMeans, width, color='g')
plt.ylabel('HARGA (US$)')
plt.title('Perbandingan Harga Emas dan Perak dunia pada tahun 1840-2011')
plt.xticks(ind+width, ('1840', '1900', '1920', '1940', '1940', '1960', '1970', '1980', '1990', '2000', '2005', '2009', '2010', '2011'))
plt.legend((rects1[0], rects2[0]), ('perak', 'emas'))
def autolabel(rects):
for rect in rects:
height = rect.get_height()
plt.text(rect.get_x()+rect.get_width()-0.5 , 1*height, '%d'%int(height), ha='left', va='bottom')
autolabel(rects1)
autolabel(rects2)
plt.show()
Sumber data statistik :
http://odnv.co.id/rasio-harga-emas-dan-perak-dari-waktu-ke-waktu