SORU
29 Temmuz 2011, Cuma


Arsa iki matplotlib ile aynı zamanda histogram

Histogram arsa dosya ve hiç bir sorun verilerini kullanarak oluşturdu. Şimdi verileri üstüne koymak istedim başka bir şey yapmam yani aynı histogram dosyası

n,bins,patchs = ax.hist(mydata1,100)
n,bins,patchs = ax.hist(mydata2,100)

ama sorun her intervale için, en yüksek değere sahip tek bar görünen, diğeri gizlidir. Acaba nasıl farklı renkler ile aynı anda iki çubuk arsa olabilir

CEVAP
29 Temmuz 2011, Cuma


Burada çalışan bir örnek var:

import random
import numpy
from matplotlib import pyplot

x = [random.gauss(3,1) for _ in range(400)]
y = [random.gauss(4,2) for _ in range(400)]

bins = numpy.linspace(-10, 10, 100)

pyplot.hist(x, bins, alpha=0.5, label='x')
pyplot.hist(y, bins, alpha=0.5, label='y')
pyplot.legend(loc='upper right')
pyplot.show()

enter image description here

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • DrakeVEVO

    DrakeVEVO

    17 AĞUSTOS 2009
  • Matthew Pearce

    Matthew Pear

    9 AĞUSTOS 2009
  • NYCarspotter

    NYCarspotter

    26 EYLÜL 2011