#!/usr/bin/env python # coding: utf-8 # # Category Plots, aka Bar Charts # In[ ]: from beakerx import * bars = CategoryBars(value= [[1, 2, 3], [1, 3, 5]]) plot = CategoryPlot() plot.add(bars) plot # In[ ]: cplot = CategoryPlot(initWidth= 400, initHeight= 200) bars = CategoryBars(value=[[1, 2, 3], [1, 3, 5]]) cplot.add(bars) # In[ ]: cplot = CategoryPlot(title= "Hello CategoryPlot!", xLabel= "Categories", yLabel= "Values") cplot.add(CategoryBars(value=[[1, 2, 3], [1, 3, 5]])) # In[ ]: cplot = CategoryPlot(categoryNames= ["Helium", "Neon", "Argon"]) cplot.add(CategoryBars(value= [[1, 2, 3], [1, 3, 5]])) # In[ ]: CategoryPlot().add(CategoryBars(value= [[1, 2, 3], [1, 3, 5]], seriesNames= ["Gas", "Liquid"])) # In[ ]: bars = CategoryBars(value= [[1, 2], [3, 4], [5, 6], [7, 8]], seriesNames= ["Gas", None, "", "Liquid"]) CategoryPlot().add(bars) # In[ ]: plot = CategoryPlot(showLegend= True) # force legend display bars = CategoryBars(value= [[1, 2, 3], [1, 3, 5]]) # since no display names were provided, default names "series0" etc will be used. plot.add(bars) # In[ ]: plot = CategoryPlot(orientation= PlotOrientationType.HORIZONTAL) plot.add(CategoryBars(value=[[1, 2, 3], [1, 3, 5]])) # In[ ]: import math plot = CategoryPlot(categoryNames= ["Acid", "Neutral", "Base"], categoryNamesLabelAngle= -1/4 * math.pi) plot.add(CategoryBars(value= [[1, 2, 3], [4, 5, 6]])) # In[ ]: CategoryPlot(categoryMargin= 2).add(CategoryBars(value= [[1, 2, 3], [4, 5, 6]])) # In[ ]: #bars = CategoryBars(value= (1..4) + 2) #CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[1, 2], [3, 4], [5, 6]], color= Color.pink) CategoryPlot().add(bars) # In[ ]: colors = [Color.red, Color.gray, Color.blue] bars = CategoryBars(value= [[1, 2], [3, 4], [5, 6]], color= colors) CategoryPlot().add(bars) # In[ ]: colors = [[Color.red, Color.gray], [Color.gray, Color.gray], [Color.blue, Color.pink]] bars = CategoryBars(value= [[1, 2], [3, 4], [5, 6]], color= colors) CategoryPlot().add(bars) # In[ ]: colors = [Color.pink, [Color.red, Color.gray, Color.blue]] bars = CategoryBars(value= [[1, 2, 3], [4, 5, 6]], color= colors) CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[1, 2, 3], [4, 5, 6]], base= -2) CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[1, 2, 3], [4, 5, 4]], base= [-1, -3]) CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[1, 2, 3], [4, 5, 6]], base= [[0, 1, 1], [-4, -5, -6]]) CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[1, 2, 3], [4, 5, 6]], width= [[0.3, 0.6, 1.7], 1.0]) CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[1, 2, 3], [4, 5, 6]], fill= [[True, True, False], [True, False, True]], drawOutline= [[True, False, True], [True, True, False]], outlineColor= [Color.black, Color.red]) CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[1, 2, 3], [4, 5, 8], [10, 9, 10]], base= [0, [1, 2, 3], [4, 5, 8]], centerSeries= True, itemLabel= [[1, 2, 3], [4, 5, 8], [10, 9, 10]] ) CategoryPlot().add(bars) # In[ ]: ss = [StrokeType.DASH, StrokeType.LONGDASH] cs = [Color.black, Color.red] CategoryPlot().add(CategoryStems(value= [[1, 2, 4], [4, 5, 8]], color= cs, style= ss)) # In[ ]: CategoryPlot().add(CategoryPoints(value= [[1, 2, 4], [4, 5, 8]])) # In[ ]: ss = [StrokeType.DASH, StrokeType.DOT] CategoryPlot().add(CategoryLines(value= [[1, 2, 4], [4, 5, 8]], style= ss, seriesNames=["Lanthanide", "Actinide"])) # In[ ]: s1 = [1, 2, 4] s2 = [4, 5, 8] lines = CategoryLines(value= [s1, s2], centerSeries= True) points = CategoryPoints(value= [s1, s2], centerSeries= True) stems = CategoryStems(value=[s1], base= [s2], style= StrokeType.DOT, color= Color.gray) #plot = CategoryPlot().add(lines).add(points).add(stems) plot = CategoryPlot() plot.add(lines) plot.add(points) plot.add(stems) # In[ ]: plot = CategoryPlot(initWidth= 500, initHeight= 400, title= "Bar Chart Demo", xLabel= "Alkali", yLabel= "Temperature ° Celcius", categoryNames=["Lithium", "Sodium", "Potassium", "Rubidium"]) s1 = [[10, 15, 13, 7], [22, 18, 28, 17]] high = [[12.4, 19.5, 15.1, 8.2], [24.3, 23.3, 30.1, 18.2]] low = [[7.6, 10.5, 10.9, 5.8], [19.7, 12.7, 25.9, 15.8]] color = [Color(247, 150, 70), Color.orange, Color(155, 187, 89)] plot.add(CategoryBars(value= s1, color= color, seriesNames= ["Solid", "Liquid"])) plot.add(CategoryStems(value= high, base= low, color= color[2])) plot.add(CategoryPoints(value= high, outlineColor= color[2], size=12)) plot.add(CategoryPoints(value= low, outlineColor= color[2], size=12)) # In[ ]: p = CategoryPlot(title= "Multiple Y Axes Demo", yLabel= "Price", categoryNames= ["Q1", "Q2", "Q3", "Q4"]) p.add(YAxis(label= "Volume", upperMargin= 1)) p.add(CategoryBars(value= [[1500, 2200, 2500, 4000]], width= 0.6, color= Color.PINK, yAxis= "Volume", showItemLabel= True, labelPosition= LabelPositionType.VALUE_INSIDE)) p.add(CategoryLines(value= [[5, 2, 3.5, 4]], color= Color.GRAY, showItemLabel=True)) p.add(CategoryPoints(value=[[5, 2, 3.5, 4]], color=Color.GRAY)) # In[ ]: CategoryPlot().add(CategoryStems(value=[[-3, 2, 4], [4, 5, 8]], width= 10, showItemLabel= True)) # In[ ]: bars = CategoryBars(value= [[-5, 2, 3], [1, 3, 5]], showItemLabel= True) CategoryPlot().add(bars) # In[ ]: bars = CategoryBars(value= [[-5, 2, 3], [1, 3, 5]], labelPosition= LabelPositionType.BASE_OUTSIDE, showItemLabel= True) CategoryPlot().add(bars) # In[ ]: plot = CategoryPlot(title= "Move mouse cursor over bars") bars = CategoryBars(value= [[-5, 2, 3], [1, 3, 5]], useToolTip= False) plot.add(bars) # In[ ]: #table = [[close=11.59, high=13.15, low=11.92, open=11.92], # [close=12.76, high=15.44, low=11.88, open=12.42], # [close=18.19, high=20.96, low=17.93, open=18.56]] #v = table.collect { it.values().toList() } #p = CategoryPlot(categoryNames= table[0].keySet().toList()) #p.add(new CategoryBars(value= v, seriesNames= ["A", "B", "C"])) # In[ ]: cs = [Color.orange] cp = CategoryPlot() cp.add(CategoryArea(value= [[1, 3, 2]], base= [[0.5, 1, 0]])) cp.add(CategoryArea(value= [[2, 1, 0.5]], color= cs))