In [ ]:
from beakerx import *
Plot(title="We Will Control the Title",
     xLabel="Horizontal",
     yLabel="Vertical")

Lines


In [ ]:
plot1 = Plot()
plot1.add(Line(x=[0, 1, 2, 3, 4, 5], y=[0, 1, 6, 5, 2, 8]))

Line properties


In [ ]:
plot2  = Plot(title= "Setting line properties")
ys = [0, 1, 6, 5, 2, 8]
ys2 = [0, 2, 7, 6, 3, 8]
plot2.add(Line(y= ys, width= 10, color= Color.red))
plot2.add(Line(y= ys, width= 3, color= Color.yellow))
plot2.add(Line(y= ys, width= 4, color= Color(33, 87, 141), style= StrokeType.DASH, interpolation= 0))
plot2.add(Line(y= ys2, width= 2, color= Color(212, 57, 59), style= StrokeType.DOT))
plot2.add(Line(y= [5, 0], x= [0, 5], style= StrokeType.LONGDASH))
plot2.add(Line(y= [4, 0], x= [0, 5], style= StrokeType.DASHDOT))

Stems


In [ ]:
plot3 = Plot()
y1 = [1.5, 1, 6, 5, 2, 8]
cs = [Color.black, Color.red, Color.gray, Color.green, Color.blue, Color.pink]
ss = [StrokeType.SOLID, StrokeType.SOLID, StrokeType.DASH, StrokeType.DOT, StrokeType.DASHDOT, StrokeType.LONGDASH]
plot3.add(Stems(y= y1, color= cs, style= ss, width= 5))

Base of Stems


In [ ]:
plot4 = Plot(title= "Setting the base of Stems")
ys = [3, 5, 2, 3, 7]
y2s = [2.5, -1.0, 3.5, 2.0, 3.0]
plot4.add(Stems(y= ys, width= 2, base= y2s))
plot4.add(Points(y= ys))

Bars


In [ ]:
plot5 = Plot(title= "Bars")
cs = [Color(255, 0, 0, 128)] * 5 
cs[3] = Color.red 
plot5.add(Bars(x= [1, 2, 3, 4, 5], y= [3, 5, 2, 3, 7], color= cs, outlineColor= Color.black, width= 0.3))

Points


In [ ]:
plot6 = Plot(title= "Changing Point Size, Color, Shape")
plot6.add(Points(y= [6, 7, 12, 11, 8, 14]))
plot6.add(Points(y= [4, 5, 10, 9, 6, 12], shape= ShapeType.CIRCLE))
plot6.add(Points(y= [2, 3, 8, 7, 4, 10], size= 8.0, shape= ShapeType.DIAMOND))
plot6.add(Points(y= [0, 1, 6, 5, 2, 8], size= 12.0, color= Color.orange, outlineColor= Color.red))

In [ ]:
plot7 = Plot(title= "Changing point properties with list")
cs = [Color.black, Color.red, Color.orange, Color.green, Color.blue, Color.pink]
ss = [6.0, 9.0, 12.0, 15.0, 18.0, 21.0]
fs = [False, False, False, True, False, False]
plot7.add([Points(y= [5] * 6, size= 12.0, color= cs),
           Points(y= [4] * 6, size= 12.0, color= Color.gray, outlineColor= cs),
           Points(y= [3] * 6, size= ss, color= Color.red),
           Points(y= [2] * 6, size= 12.0, color= Color.black, fill= fs, outlineColor= Color.black)])

Areas


In [ ]:
plot8 = Plot()
y = [3, 5, 2, 3]
x0 = [0, 1, 2, 3]
x1 = [3, 4, 5, 8]
plot8.add(Area(x= x0, y= y))
plot8.add(Area(x= x1, y= y, color= Color(128, 128, 128, 50), interpolation= 0))

In [ ]:
plot9 = Plot()
plot9.add(Line(y= [3, 6, 12, 24], displayName= "Median"))
plot9.add(Area(y= [4, 8, 16, 32], base= [2, 4, 8, 16],
              color= Color(255, 0, 0, 50), displayName= "Q1 to Q3"))

XYStacker


In [ ]:
y1 = [1,5,3,2,3]
y2 = [7,2,4,1,3]
plot10 = Plot(title= 'Plot with XYStacker', initHeight= 200)
a1 = Area(y= y1, displayName= 'y1')
a2 = Area(y= y2, displayName= 'y2')
stacker = XYStacker()
plot10.add(stacker.stack([a1, a2]))

ConstantLines and ConstantBands


In [ ]:
plot11 = Plot()
plot11.add(Line(y= [-1, 1]))
plot11.add(ConstantLine(x= 0.65, style= StrokeType.DOT, color= Color.blue))
plot11.add(ConstantLine(y= 0.1, style= StrokeType.DASHDOT, color= Color.blue))
plot11.add(ConstantLine(x= 0.3, y= 0.4, color= Color.gray, width= 5, showLabel= True))

In [ ]:
plot12 = Plot() 
plot12.add(Line(y= [-3, 1, 3, 4, 5]))
plot12.add(ConstantBand(x= [1, 2], y= [1, 3]))

In [ ]:
plot13 = Plot() 
plot13.add(Line(x= [-3, 1, 2, 4, 5], y= [4, 2, 6, 1, 5]))
plot13.add(ConstantBand(x= [-3, 1], color= Color(128, 128, 128, 50)))
plot13.add(ConstantBand(x= [1, 2]))
plot13.add(ConstantBand(x= [4, 6]))

Text


In [ ]:
from beakerx.plot import Text as BeakerxText
plot14 = Plot()
xs = list(range(1, 11))
ys = [8.6, 6.1, 7.4, 2.5, 0.4, 0.0, 0.5, 1.7, 8.4, 1]
label = ['', 'min', 'max', 'falling', 'falling', 'min', 'rising', 'rising', 'max', '']          
for i in range(1, 9):
    plot14.add(BeakerxText(x= xs[i], y= ys[i], text= label[i],  pointerAngle= -i/3.0))
    
plot14.add(Line(x= xs, y= ys))
plot14.add(Points(x= xs, y= ys))

Crosshair


In [ ]:
ch = Crosshair(color= Color(255, 128, 5), width= 2, style= StrokeType.DOT)
plot15 = Plot(crosshair= ch, omitCheckboxes= True, legendLayout= LegendLayout.HORIZONTAL)
x = [1, 4, 6, 8, 10]
y = [3, 6, 4, 5, 9]
plot15.add(Line(displayName= "Line", x= x, y= y, width= 3))
plot15.add(Bars(displayName= "Bar", x= range(1, 11), y= [2, 2, 4, 4, 2, 2, 0, 2, 2, 4], width= 0.5))
plot15.add(Points(x= x, y= y, size= 10))

In [ ]:
plot15.setLegendPosition(LegendPosition.RIGHT)

SimpleTimePlot


In [ ]:
import pandas as pd
tableRows = pd.read_csv('../../../doc/resources/data/interest-rates.csv')

In [ ]:
SimpleTimePlot(tableRows, ["y1", "y10"], # column names,
                   timeColumn="time", # time is default value for a timeColumn,
                   displayNames=["1 Year", "10 Year"])

Milliseconds resolution


In [ ]:
import time

millis = 1507541201624;
hour = round(1000 * 60 * 60);
xs = [];
ys = [];
for i in range(11):
    xs.append(millis + hour * i);
    ys.append(i);

plot = TimePlot(timeZone="America/New_York")
# list of milliseconds
plot.add(Points(x=xs, y=ys))

Nanoseconds resolution


In [ ]:
import time

millis = 1507541201624;
nanos  = millis * 1000 * 1000
xs = []
ys = []
for i in range(11):
    xs.append(nanos + 7 * i)
    ys.append(i);

np = NanoPlot()
np.add(Points(x=xs, y=ys))

Second Y Axis


In [ ]:
sp = Plot()
sp.add(YAxis(label= "Test y axis"))
sp.add(Line(
        x=pd.Series([10, 20, 30, 40, 50, 60, 70]), 
        y=pd.Series([0, 60, 10, 50, 20, 40, 30])))
sp.add(Line(
        x=pd.Series([5, 15, 25, 35, 45, 55, 65]), 
        y=pd.Series([5, 65, 15, 55, 25, 45, 35]), yAxis= "Test y axis"))

Logarithmic Scale


In [ ]:
import math
points = 100;
xs = [];
for i in range(0, points):
  xs.append(i)

cplot = CombinedPlot(xLabel= "CombinedPlot");

linearPlot = Plot(title= "Linear x, Linear y");
linearPlot.add(Line(x= xs, y= xs));
cplot.add(linearPlot, 3);

logYPlot = Plot(logY= True, logX=False, title= "Linear x, Log y");
logYPlot.add(Line(x= xs, y= xs));
cplot.add(logYPlot, 3);

logYPlot = Plot(logY= False, logX=True, title= "Log x, Linear y");
logYPlot.add(Line(x= xs, y= xs));
cplot.add(logYPlot, 3);

cplot

In [ ]: