Category Plots, aka Bar Charts


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [1, 3, 5]])
new CategoryPlot() << bars

the initWidth and initHeight properties


In [ ]:
def cplot = new CategoryPlot(initWidth: 400, initHeight: 200)
def bars = new CategoryBars(value:[[1, 2, 3], [1, 3, 5]])
cplot << bars

the title, x and y axis labels


In [ ]:
def cplot = new CategoryPlot(title: "Hello CategoryPlot!",
                             xLabel: "Categories",
                             yLabel: "Values")
cplot << new CategoryBars(value:[[1, 2, 3], [1, 3, 5]])

the category labels


In [ ]:
def cplot = new CategoryPlot(categoryNames: ["Helium", "Neon", "Argon"])
cplot << new CategoryBars(value: [[1, 2, 3], [1, 3, 5]])

the series labels


In [ ]:
def bars = new CategoryBars(value: [[1, 2], [3, 4], [5, 6], [7, 8]],
                            seriesNames: ["Gas", null, "", "Liquid"])
new CategoryPlot() << bars

the legend


In [ ]:
def plot = new CategoryPlot(showLegend: true) // force legend display
def bars = new CategoryBars(value: [[1, 2, 3], [1, 3, 5]])
// since no display names were provided, default names "series0" etc will be used.
plot << bars

the orientation


In [ ]:
def plot = new CategoryPlot(orientation: PlotOrientationType.HORIZONTAL)
plot << new CategoryBars(value:[[1, 2, 3], [1, 3, 5]])

the label angle


In [ ]:
def plot = new CategoryPlot(categoryNames: ["Acid", "Neutral", "Base"], 
                            categoryNamesLabelAngle: -1/4 * Math.PI)
plot << new CategoryBars(value: [[1, 2, 3], [4, 5, 6]])

the margin


In [ ]:
new CategoryPlot(categoryMargin: 2) << new CategoryBars(value: [[1, 2, 3], [4, 5, 6]])

the color (single value)


In [ ]:
def bars = new CategoryBars(value: [[1, 2], [3, 4], [5, 6]], 
                            color: Color.pink)
new CategoryPlot() << bars

the color (list of values)


In [ ]:
def colors = [Color.pink, [Color.red, Color.gray, Color.blue]]
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]], 
                            color: colors)
new CategoryPlot() << bars

the base (single value)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]], 
                            base: -2)
new CategoryPlot() << bars

the base (list of values)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            base: [-2, [-4, -4, -1]])
new CategoryPlot() << bars

the width (single value)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            width: 0.3)
new CategoryPlot() << bars

the width (list of values)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            width: [[0.3, 0.6, 1.7], 1.0])
new CategoryPlot() << bars

the fill (single value)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            fill: false)
new CategoryPlot() << bars

the fill (list of values)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            fill: [[false, true, false], true])
new CategoryPlot() << bars

draw outline (single value)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            drawOutline: true)
new CategoryPlot() << bars

draw otline (list of values)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            drawOutline: [[false, true, false], true])
new CategoryPlot() << bars

outline color (single value)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            drawOutline: true,
                            outlineColor: Color.green)
new CategoryPlot() << bars

outline color (list of values)


In [ ]:
def bars = new CategoryBars(value: [[1, 2, 3], [4, 5, 6]],
                            drawOutline: true,
                           outlineColor: [Color.green, Color.red])
new CategoryPlot() << bars

In [ ]: