
// BarPlots.java
// Yuriy Guskov
// Modified by Andrew Davison, ad@coe.psu.ac.th, March 2023

/* A graph using column and row bars.

   Usage:
     > compile BarPlots.java
     > run BarPlots
*/


import java.awt.*;

import com.github.plot.Plot;
import com.github.plot.Plot.*;


public class BarPlots
{

  public static void main(String[] args)
  {
    // configure options
    PlotOptions pOpts = Plot.plotOpts().
             title("Bar Plots").
             width(800).height(450).  // total plot size
             legend(Plot.LegendFormat.TOP);

    AxisOptions axOpts = Plot.axisOpts().range(0, 10);

    // build the plot
    Plot plot = Plot.plot(pOpts);
    plot.xAxis("x", axOpts);  // both axes use same range
    plot.yAxis("y", axOpts);

    // data 1
    DataSeriesOptions dsOpts1 = Plot.seriesOpts().
                       line(Line.NONE).
                       marker(Plot.Marker.BAR).
         // the bar will be a row starting at the y-axis
                       markerColor(Color.GREEN).
                         // the color inside the bar
                       color(Color.GREEN);
    Plot.Data plotData1 = Plot.data().
                  xy(2, 7).xy(3, 8).xy(4, 6);
    plot.series("f1", plotData1, dsOpts1);


    // data 2
    DataSeriesOptions dsOpts2 = Plot.seriesOpts().
                       line(Line.NONE).
                       markerColor(Color.BLUE).
                       marker(Plot.Marker.COLUMN);
         // the bar will be a column starting at the x-axis

    Plot.Data plotData2 = Plot.data().
                  xy(7, 2).xy(8, 4).xy(9, 3);
    plot.series("f2", plotData2, dsOpts2);

    Utils.viewPlot("Bar Plots", plot);
  }  // end of main()


}  // end of BarPlots class