TUGAS PROBABILITAS DAN STATISTIKA

1

Bookmark and Share



TUGAS PROBABILITAS DAN STATISTIKA


PLOTING DATA DENGAN MENGGUNAKAN  Python 3.2.5


OLEH :


MUHAMMAD SYAFRUDDIN
0915031094

PROBSTAT KELAS B




Berikut hasil capture grafik, disini saya menggunakan jenis HISTOGRAM :






Berikut script Python 3.2.5 :

import numpy as np
import matplotlib.pyplot as plt

N = 11

tambakMeans = (131, 172, 174, 156, 193, 91, 126, 135, 145, 148,150 )

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

plt.subplot(111)
rects1 = plt.bar(ind, tambakMeans, width,
                    color='r',
                    error_kw=dict(elinewidth=5, ecolor='pink'))

pembenihanMeans = (67, 85, 85, 89, 104, 30, 54, 59, 54, 51, 51)


rects2 = plt.bar(ind+width, pembenihanMeans, width,

                    color='y',
                   
                    error_kw=dict(elinewidth=5, ecolor='yellow'))

airtawarMeans = (4, 7, 7, 8, 8, 4, 9, 13, 7, 6, 6)

rects3 = plt.bar(ind+width, airtawarMeans, width,

                    color='b',
                   
                    error_kw=dict(elinewidth=5, ecolor='yellow'))

# add some

plt.ylabel('nilai')
plt.title('Jumlah Perusahaan Budidaya Perikanan Menurut Jenis Budidaya, 2000-2010')
plt.xticks(ind+width, ('2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010') )

plt.legend( (rects1[0], rects2[0], rects3[0]), ('Tambak ', 'Pembenihan', 'Air Tawar',) )


def autolabel(rects):

    # attach some text labels
    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)

plt.show()



Berikut penjelasan source codenya :

 pada tugas ini saya menggunakan sumber data dari :


  1. N = 11tambakMeans = (131, 172, 174, 156, 193, 91, 126, 135, 145, 148,150 )
    pembenihanMeans = (67, 85, 85, 89, 104, 30, 54, 59, 54, 51, 51)
    airtawarMeans = (4, 7, 7, 8, 8, 4, 9, 13, 7, 6, 6)

    diatas merupakan data yang saya input. jenis budidaya : tambak,pembenihan,ait tawar.

       2000 2001 2002 2003 2004 2005 2006 2007 2008 2009     2010
    Tambak 131 172 174 156 193 91 126 135 145 148       150
    Pembenihan 67 85 85 89 104 30 54 59 54 51         51
    Air Tawar 4 7 7 8 8 4 9 13 7 6            6



































    # add some
    plt.ylabel('nilai')  ====>  label di tampilan
    plt.title('Jumlah Perusahaan Budidaya Perikanan Menurut Jenis Budidaya, 2000-2010')      
    plt.xticks(ind+width, ('2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010')  =====> label di tampilan


Read More >>