Histograms

In a histogram, the height of each bar (bin) represents the number of data points that fall into its interval. They are generally used to show the distribution of a variable.


In [ ]:
# Generate some random data
import random
from beakerx import *
data1 = []
data2 = []

for x in range(1, 10000):
  data1.append(random.gauss(0, 1))  
  data2.append(2*random.gauss(0, 1) + 1.0)

In [ ]:
Histogram(data= data1, binCount= 25)

In [ ]:
Histogram(
    initWidth=800,
    initHeight=200,
              title="Wide Histogram with Manual Parameters",
              xLabel="Size",
              yLabel="Count",
              rangeMin= -8, 
              rangeMax= 8, 
              data= data1,
              binCount= 99, 
              color= Color(0, 154, 166))

In [ ]:
Histogram(title= "Default is Overlap",
              data=  [data1, data2],
              binCount=  99,
              names= ["old and tired", "new and improved"],
              color= [Color(0, 154, 166),
                      Color(230, 50, 50, 128) # transparent!
                     ])

In [ ]:
Histogram(title= "Stack",
              showLegend= False,
              displayMode= Histogram.DisplayMode.STACK,
              data= [data1, data2],
              binCount= 99)

In [ ]:
Histogram(title= "Side by Side",
              displayMode=  Histogram.DisplayMode.SIDE_BY_SIDE,
              data = [data1,data2], 
              binCount= 55)

In [ ]:
Histogram(title= "Cumulative",
              cumulative= True,
              data= data1,
              binCount= 55)

In [ ]:
Histogram(title= "Normed, Area = 1.0",
              normed= True,
              data= data1,
              binCount= 55)

In [ ]:
Histogram(log= True, data= data1, binCount= 99)