#!/usr/bin/env python # coding: utf-8 # In[1]: from beakerx import * Plot(title="test title", xLabel="x label", yLabel="y label") # In[2]: plot1 = Plot() plot1.add(Bars(displayName="Bar", x=[20,40,60], y=[100, 120, 90], width=10)) # In[3]: plot2 = Plot() plot2.add(Line(x=[1, 5, 3], y=[1, 2, 6])) # In[4]: plot3 = Plot() plot3.add(Points(y=[1, 3, 6, 3, 1], x=[1, 2, 3, 4, 5], size=10, shape=ShapeType.DIAMOND)) # In[5]: plot4 = Plot(); plot4.add(Stems(y= [1.5, 1, 6, 5])) # In[6]: plot5 = Plot(crosshair = Crosshair()) plot5.add(Area(x = [0, 1, 2, 3], y = [3, 5, 2, 3])) # In[7]: Plot().add(ConstantLine(y=0.1)).add(ConstantLine(x=0.3, y=0.4, color=Color.gray, showLabel=True)) # In[8]: Plot().add(Line(y=[-3, 1, 3, 4, 5])).add(ConstantBand(x=[1, 2], y=[1, 3])) # In[9]: from beakerx.plot import Text as BeakerxText plot = Plot() xs = [1, 2, 3, 4] ys = [8.6, 6.1, 7.4, 2.5] for i in range(0, 4): plot.add(BeakerxText(x= xs[i], y= ys[i], text= 'test')) plot.add(Line(x= xs, y= ys)) # In[10]: import pandas as pd tableRows = pd.read_csv('../../../doc/resources/data/interest-rates.csv') pp1 = Plot() pp1.add(Bars(y=tableRows.y1)) # In[11]: pp2 = Plot() pp2.add(Line( x=pd.Series([10, 20, 30, 40, 50, 60, 70]), y=pd.Series([0, 60, 10, 50, 20, 40, 30]), width=5)) # In[12]: y1 = [1,5,3,2,3] y2 = [1,2,4,1,3] p = Plot() a1 = Area(y=y1, displayName='y1') a2 = Area(y=y2, displayName='y2') stacker = XYStacker() p.add(stacker.stack([a1, a2])) # In[13]: SimpleTimePlot(tableRows, ["y1", "y10"], # column names timeColumn="time", # time is default value for a timeColumn displayNames=["1 Year", "10 Year"]) # In[14]: 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)) # In[15]: millis = 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)) # In[16]: 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")) # In[17]: 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[ ]: