SORU
16 Mart 2011, ÇARŞAMBA


Histogram Matplotlib

Küçük bir sorunum var. Zaten histogram biçiminde olan scipy bir veri seti var, bidonları merkezi ve bin başına olay sayısı var. Şimdi nasıl bir komplo histogram olarak yapabilirim. Sadece yapmaya çalıştım

bins, n=hist()

ama öyle olmadı. Herhangi bir öneriler?

CEVAP
16 Mart 2011, ÇARŞAMBA


import matplotlib.pyplot as plt
import numpy as np

mu, sigma = 100, 15
x = mu   sigma * np.random.randn(10000)
hist, bins = np.histogram(x, bins=50)
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1]   bins[1:]) / 2
plt.bar(center, hist, align='center', width=width)
plt.show()

enter image description here

Nesne yönelimli arayüzü de basittir:

fig, ax = plt.subplots()
ax.bar(center, hist, align='center', width=width)
fig.savefig("1.png")

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Angry Paintballer

    Angry Paintb

    8 Ocak 2012
  • glowpinkstah

    glowpinkstah

    16 Mayıs 2006
  • Videogamerz | Call of Duty

    Videogamerz

    5 NİSAN 2012