
// ScatterPlots.java
// Yuriy Guskov
// Modified by Andrew Davison, ad@coe.psu.ac.th, March 2023

/* Two scatter plots drawn on one graph using differently
   shaped markers and colors. The legend is positioned above
   the graph.

   Usage:
     > compile ScatterPlots.java
     > run ScatterPlots
*/


import java.awt.*;

import com.github.plot.Plot;
import com.github.plot.Plot.*;


public class ScatterPlots
{

  public static void main(String[] args)
  {
    // configure options
    PlotOptions pOpts = Plot.plotOpts().
             title("Scatter Plots").
             width(800).height(450). // total plot size
             legend(Plot.LegendFormat.TOP);

    AxisOptions axOpts = Plot.axisOpts().
         format(Plot.AxisFormat.NUMBER_INT).
         range(0, 10);    // integers from 0 to 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).
                       color(Color.BLACK).
                         // used for the marker outline
                       marker(Plot.Marker.CIRCLE).
                       markerColor(Color.CYAN).
                       markerSize(12);
    Plot.Data plotData1 = Plot.data().
                  xy(4, 9).xy(5, 8).xy(6, 9);
    plot.series("f1", plotData1, dsOpts1);


    //  data 2
    DataSeriesOptions dsOpts2 = Plot.seriesOpts().
                        line(Line.NONE).
                        marker(Plot.Marker.SQUARE).
                        markerColor(Color.CYAN);
                    // default marker outline is blue
    Plot.Data plotData2 = Plot.data().
                  xy(6, 5).xy(7, 6).xy(8, 8);
    plot.series("f2", plotData2, dsOpts2);


    Utils.viewPlot("Scatter Plots", plot);
  }  // end of main()


}  // end of ScatterPlots class