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

  • Edge-CGI 3D Tutorials and more!

    Edge-CGI 3D

    11 HAZİRAN 2013
  • Joseph Herscher

    Joseph Hersc

    14 Mart 2007
  • Shantanu Sood

    Shantanu Soo

    3 Kasım 2008