简体   繁体   English

使用JFreeChart的箱形图

[英]Box plot using JFreeChart

First off, I am new to Java and to Stackoverflow. 首先,我是Java和Stackoverflow的新手。 So I hope I can supply enough clarity in my question. 因此,我希望我可以在我的问题中提供足够的清晰度。

My goal is to create a box plot using jfreechart to keep track of measurement values from every day use. 我的目标是使用jfreechart创建箱形图,以跟踪日常使用中的测量值。 I want to do this by storing minimal amount of data ie. 我想通过存储最少的数据来做到这一点。 by storing statists of mean, standard deviation, median, 1Q,3Q, min and maximum. 通过存储平均值,标准差,中位数,1Q,3Q,最小值和最大值的统计信息。 This should then be visualized by a box plot for each day measured. 然后应通过每天测量的箱形图将其可视化。

I have looked at the box plot demo here http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm 我在这里查看了箱形图演示http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm

In this demo they create the dataset and add all the values to the dataset, then adds it to the plot. 在此演示中,他们创建了数据集并将所有值添加到数据集中,然后将其添加到绘图中。 The dataset itself contains methods to return the mean, median etc. of the dataset to be able to create the plot. 数据集本身包含返回数据集的平均值,中位数等的方法,以便能够创建绘图。 See the code below for a snip from the demo in the link above. 请参阅下面的代码,以获取上面链接中的演示片段。

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    //some type of algorithm to add values to the dataset
    dataset.add(//values, series and type here);
    // Return the finished dataset
    CategoryAxis xAxis = new CategoryAxis("Type");
    NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis,
            renderer);

    JFreeChart chart = new JFreeChart("Box-and-Whisker Demo",
            new Font("SansSerif", Font.BOLD, 14), plot, true);

So my question is, how should I do to just add the median, Q1,Q3, mean, minimum and maximum values to create the box plot? 所以我的问题是,我应该怎么做才能将中位数,Q1,Q3,均值,最小值和最大值相加来创建箱形图? Because in the demo above they base the plot of a complete sample set. 因为在上面的演示中,它们基于完整样本集的图。

You can create your own dataset class and use it to create the chart. 您可以创建自己的数据集类并使用它来创建图表。

Create your own implementation of BoxAndWhiskerCategoryDataset and use it in place of DefaultBoxAndWhiskerCategoryDataset . 创建您自己的BoxAndWhiskerCategoryDataset实现,并使用它代替DefaultBoxAndWhiskerCategoryDataset

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM