Box plot using XChart
Code: "xchart_box.java". Programming language: Java
DMelt Version 3. Last modified: 04/05/1977. License: Pro
https://datamelt.org/code/cache/xchart_box_654.java
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
import java.util.Arrays;
import org.knowm.xchart.BoxChart;
import org.knowm.xchart.BoxChartBuilder;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.style.Styler.ChartTheme;
/*
* Box Chart with 3 series
*/
public class xchart_box {
public static void main(String[] args) {
BoxChart chart = getChart();
new SwingWrapper(chart).displayChart();
}
static public BoxChart getChart() {
// Create Chart
BoxChart chart =
new BoxChartBuilder()
.title("box plot demo")
.xAxisTitle("X")
.yAxisTitle("Y")
.theme(ChartTheme.GGPlot2)
.build();
// Series
chart.addSeries("aaa", Arrays.asList(40, 30, 20, 60, 50));
chart.addSeries("bbb", Arrays.asList(-20, -10, -30, -15, -25));
chart.addSeries("ccc", Arrays.asList(50, -20));
return chart;
}
public String getExampleChartName() {
return getClass().getSimpleName() + "- 3 Boxes";
}
}
You see the box below because you did not login.