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

  • DetroitBORG

    DetroitBORG

    29 Temmuz 2008
  • HER0R

    HER0R

    16 Aralık 2007
  • Matthew Pearce

    Matthew Pear

    9 AĞUSTOS 2009