This small visualization is about boxplot graphs. A boxplot represents in just five numbers (Min, Max, Q25, Q75 and Median) every kind of interval of observations. If you have difficoulty remembering what a boxplot represents then have a look at boxplot article of Wikipedia
For this visualization we will use a Java library that is JFreeChart. JFreeChart is an open source library and it is free to use. Import it to your Java project and lets make the Java code that will visualize the boxplot graphics
Basically in this code we will :
1 - generate an interval of values to use it for the boxplot representation
2 - make the methods for representing the graph itself
The Java code for the boxplot graphic is ready to use and you can copy paste it in your Eclipse IDE after importing the jfreechart.jar file in your project
public class MyBoxPlot extends ApplicationFrame { // the MyBoxPlot library will extend the ApplicationFrame class form JFreeChart library public MyBoxPlot(String titel) { // build the constructor of the class final BoxAndWhiskerXYDataset dataset = createDataset(); final ChartPanel chartPanel = new ChartPanel(chart); } private BoxAndWhiskerXYDataset createDataset() { // this method will generate the interval of random values to be represented as boxplots } private JFreeChart createChart(final BoxAndWhiskerXYDataset dataset) { // this method creates the chart itself } public static void main(final String[] args) { // finaly we visualize it using the main method by } And the result is as follows If you liked this guide follow datatreemap and stay tuned for more guides on programming and data visualization.
super(titel); // call the constructor of ApplicationFrame
final JFreeChart chart = createChart(dataset);
chartPanel.setPreferredSize(new java.awt.Dimension(700, 400));
setContentPane(chartPanel);
final int ENTITY_COUNT = 14; DefaultBoxAndWhiskerXYDataset dataset = new
DefaultBoxAndWhiskerXYDataset("My BoxPlot Graphics");
for (int i = 0; i ENTITY_COUNT; i++) {
Date date = DateUtilities.createDate(2003, 7, i + 1, 12, 0);
List values = new ArrayList();
for (int j = 0; j 10; j++) {
values.add(new Double(10.0 + Math.random() * 10.0));
values.add(new Double(13.0 + Math.random() * 4.0));
}
dataset.add(date,
BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values));
}
return dataset;
JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(
"Box and Whisker Chart", "Time", "Value", dataset, true);
chart.setBackgroundPaint(new Color(249, 231, 236)); return chart;
final MyBoxPlot demo = new MyBoxPlot(""); // creating the MyBoxPlot object called demo
demo.pack(); // call the method pack() in it
RefineryUtilities.centerFrameOnScreen(demo); // center it in the screen
demo.setVisible(true); // and make it visible
}
Hi! I am a robot. I just upvoted you! Readers might be interested in similar content by the same author:
https://steemit.com/visualization/@datatreemap/visualize-a-boxplot-graph-with-jfreechart-in-java
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit