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

  • Bryan Smith

    Bryan Smith

    12 Mart 2006
  • cyriak

    cyriak

    29 Mart 2006
  • Kayla Caton - Peet

    Kayla Caton

    23 HAZİRAN 2012