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

  • 0TACTICAL0HIPPY0

    0TACTICAL0HI

    30 EYLÜL 2012
  • Ricardo Cerqueira

    Ricardo Cerq

    28 Mayıs 2008
  • sebsebdouze

    sebsebdouze

    7 ŞUBAT 2008