groupedBar

Create an array of bar plots that, when inserted into a Figure, will effectively become a grouped bar plot.

  1. BarPlot[] groupedBar(R1 centers, R2 data, double width, string[] legendText, Color[] colors)
    groupedBar
    (
    R1
    R2
    )
    (,
    R2 data
    ,
    double width
    ,
    string[] legendText = null
    ,
    Color[] colors = null
    )
    if (
    isInputRange!R1 &&
    isRoR!R2
    )
  2. BarPlot[] groupedBar(R1 centers, R2 data, R3 lowerErrors, R4 upperErrors, double width, string[] legendText, Color[] colors)

Examples

// Make a plot with three groups:  One for "In Meeting", one for "On Phone",
// and one for "Coding".  The plot will also have two bar colors:  One for
// "Without Caffeine" and one for "With Caffeine".
auto withoutCaffeine = [8, 6, 3];
auto withCaffeine = [5, 3, 1];
auto sleepinessPlot = groupedBar(
    iota(3), [withoutCaffeine, withCaffeine], 0.6,
    ["W/o Caffeine", "W/ Caffeine"],
    [getColor(64, 64, 255), getColor(255, 64, 64)]
);
auto sleepinessFig = Figure(sleepinessPlot)
    .title("Sleepiness Survey")
    .yLabel("Sleepiness Rating")
    .xLabel("Activity")
    .legendLocation(LegendLocation.right)
    .horizontalGrid(true)
    .xTickLabels(
        iota(3),
        ["In Meeting", "On Phone", "Coding"]
    );

Meta