examples.plotting.example3.Example3 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jstat Show documentation
Show all versions of jstat Show documentation
Java Library for Statistical Analysis.
The newest version!
package examples.plotting.example3;
import dataloader.CsvDataLoader;
import datastructs.IVector;
import tech.tablesaw.api.Table;
import visualizations.LineChart;
import java.io.File;
import java.io.IOException;
/**
* Category: Plotting
* ID: PlotALine
* Description: Load a CSV file and plot two columns against each other
*/
public class Example3 {
public static void main(String[] args) throws IOException {
File file = new File("data/annual.csv");
Table table = CsvDataLoader.TableLoader.parseFile(file);
// extract numeric samples from the data
IVector X = CsvDataLoader.TableLoader.buildNumericSample(table, "Year");
IVector Y = CsvDataLoader.TableLoader.buildNumericSample(table, "Mean");
LineChart plotter = new LineChart();
LineChart.LineChartOptions options = plotter.new LineChartOptions();
options.chartTitle = "Per Year Mean";
options.xAxisName = "Year";
options.yAxisName = "Mean";
LineChart.plotLine(X, Y, options);
}
}