Histogram çizimi

Python ile İstatistiksel Düşünme (Bölüm 1)

Justin Bois

Teaching Professor at the California Institute of Technology

2008 ABD salıncak eyalet seçim sonuçları

Veriler Data.gov'dan alınmıştır (https://www.data.gov/)

ch1-2.003.png

Python ile İstatistiksel Düşünme (Bölüm 1)

Histogram oluşturma

import matplotlib.pyplot as plt
_ = plt.hist(df_swing['dem_share'])
_ = plt.xlabel('Obama için oy yüzdesi')
_ = plt.ylabel('ilçe sayısı')
plt.show()
Python ile İstatistiksel Düşünme (Bölüm 1)

Eksenleri her zaman etiketleyin

Python ile İstatistiksel Düşünme (Bölüm 1)

2008 ABD salıncak eyalet seçim sonuçları

Veriler Data.gov'dan alınmıştır (https://www.data.gov/)

ch1-2.013.png

Python ile İstatistiksel Düşünme (Bölüm 1)

Farklı kutulamalı histogramlar

Veriler Data.gov'dan alınmıştır (https://www.data.gov/)

ch1-2.015.png

Python ile İstatistiksel Düşünme (Bölüm 1)

Histogramın kutularını ayarlama

bin_edges = [0, 10, 20, 30, 40, 50,
                60, 70, 80, 90, 100]
_ = plt.hist(df_swing['dem_share'], bins=bin_edges)
plt.show()

ch1-2.022.png

Python ile İstatistiksel Düşünme (Bölüm 1)

Histogramın kutularını ayarlama

_ = plt.hist(df_swing['dem_share'], bins=20)
plt.show()

ch1-2.027.png

Python ile İstatistiksel Düşünme (Bölüm 1)

Seaborn

  • Michael Waskom tarafından yazılmış, Matplotlib tabanlı mükemmel bir istatistiksel görselleştirme paketi
Python ile İstatistiksel Düşünme (Bölüm 1)

Seaborn stilini ayarlama

import seaborn as sns
sns.set()
_ = plt.hist(df_swing['dem_share'])
_ = plt.xlabel('Obama için oy yüzdesi')
_ = plt.ylabel('ilçe sayısı')
plt.show()
Python ile İstatistiksel Düşünme (Bölüm 1)

Seaborn stilli bir histogram

ch1-2.038.png

1 Veriler Data.gov'dan alınmıştır (https://www.data.gov/)
Python ile İstatistiksel Düşünme (Bölüm 1)

Hadi pratik yapalım!

Python ile İstatistiksel Düşünme (Bölüm 1)

Preparing Video For Download...