examples.plotting.example3.example.md 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!
# Example 3: Line Plot
## Contents
* [Overview](#overview)
* [Import files](#include_files)
* [The main function](#m_func)
* [Results](#results)
* [Source Code](#source_code)
## Overview
## Import files
```
import dataloader.CsvDataLoader;
import datastructs.NumericSample;
import tech.tablesaw.api.Table;
import visualizations.LineChart;
import java.io.File;
import java.io.IOException;
```
## The main function
```
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
NumericSample X = CsvDataLoader.TableLoader.buildNumericSample(table, "Year");
NumericSample 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);
}
}
```
## Results
```
```
## Source Code
Example3.java