Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在JFreeChart中创建一个简单的箱线图_Java_Jfreechart - Fatal编程技术网

Java 在JFreeChart中创建一个简单的箱线图

Java 在JFreeChart中创建一个简单的箱线图,java,jfreechart,Java,Jfreechart,我无法将数据集转换为使用JFreeChart创建框须图的正确格式: 我见过几个在列表中创建数组的例子,但我只有两个列表,所以我想我可以将它们添加到数据集中的一个列表中。然而,我只得到一张空白的图表(如中所示,我可以看到图表,但上面没有数据)。没有错误,只是什么都没有。有人能告诉我如何得到正确形状的数据吗? 数据集包含一个多维数组,其构造如下: final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhisker

我无法将数据集转换为使用JFreeChart创建框须图的正确格式:

我见过几个在列表中创建数组的例子,但我只有两个列表,所以我想我可以将它们添加到数据集中的一个列表中。然而,我只得到一张空白的图表(如中所示,我可以看到图表,但上面没有数据)。没有错误,只是什么都没有。有人能告诉我如何得到正确形状的数据吗? 数据集包含一个多维数组,其构造如下:

 final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
               List<List<Double>> Overall = new ArrayList<List<Double>>();
               double[] weights_LArr = new double[weights_L.size()];
               double[] weights_RArr = new double[weights_R.size()];
               List<Double> listL = new ArrayList<Double>();
               List<Double> listR = new ArrayList<Double>();

                              for ( int i = 0; i < weights_LArr.length; i++) {
                                weights_LArr[i] = weights_L.get(i);                
                                listL.add(weights_L.get(i));  
                              }



                            for ( int i = 0; i < weights_RArr.length; i++) {
                                weights_RArr[i] = weights_R.get(i); 
                                listR.add(weights_R.get(i));    
                              }        

                    Overall.add(listL);
                    Overall.add(listR);
                    dataset.add(Overall, "Type ", " Number ");



final BoxAndWhiskerCategoryDataset datasetBW = dataset;

         final CategoryAxis xAxis = new CategoryAxis("Type");
         final NumberAxis yAxis = new NumberAxis("Value");
         yAxis.setAutoRangeIncludesZero(false);
         final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
         renderer.setFillBox(false);
         final CategoryPlot plot = new CategoryPlot(datasetBW, xAxis, yAxis, renderer);
         final JFreeChart chart = new JFreeChart(
                            "Box-and-Whisker Demo",
                            new Font("SansSerif", Font.BOLD, 14),
                            plot,
                            true
                        );
        final ChartPanel chartPanel = new ChartPanel(chart);
                     // ChartPanel chartpanel = new ChartPanel(chart);
                    chartPanel.setDomainZoomable(true);

                    JPanel jPanel4 = new JPanel();
                    jPanel4.setLayout(new BorderLayout());
                    jPanel4.add(chartPanel, BorderLayout.NORTH);

                    JFrame frame = new JFrame();
                    frame.add(jPanel4);
                    frame.pack();
                    frame.setVisible(true);
final DefaultBoxAndWhiskerCategoryDataset=new DefaultBoxAndWhiskerCategoryDataset();
列表整体=新的ArrayList();
double[]weights_LArr=新的double[weights_L.size()];
double[]weights_RArr=新的double[weights_R.size()];
List listL=new ArrayList();
List listR=new ArrayList();
对于(int i=0;i
数据集的方法需要值的
列表,而不是
列表。看看这个,试试这样的方法:

dataset.add(listL, "Weights", "Left");
dataset.add(listR, "Weights", "Right");