Physics Graph
This code provides a visualization for my physics data
For my AP Physics lab, we had to measure out the speeds of a slow & fast car and then graph them which is shown below, using the XChart library.
import java.util.List;
import java.util.stream.Collectors;
%%loadFromPOM
<dependency>
<groupId>org.knowm.xchart</groupId>
<artifactId>xchart</artifactId>
<version>3.5.2</version>
</dependency>
%maven org.knowm.xchart:xchart:3.5.2
import org.knowm.xchart.*;
double[] xData = { 0.0, 2.71, 5.61 };
double[] xData2 = { 0.0, 1.4, 2.55 };
double[] yData = { 0.0, 1.0, 2.0 };
double[] yData2 = { 2.0, 1.0, 0.0 };
XYChart chart = new XYChartBuilder().title("Position vs Time").xAxisTitle("Time (s)").yAxisTitle("Position (m)").build();
chart.addSeries("Slow Car", xData, yData);
chart.addSeries("Fast Car", xData2, yData);
chart.addSeries("Reverse Slow Car", xData, yData2);
BitmapEncoder.getBufferedImage(chart);
BitmapEncoder.getBufferedImage(chart2);