使用jFreeChart绘制滞后循环

我需要绘制磁滞回线,然后计算循环内闭合的区域。 我正在使用jFreeChart。

考虑以下数据:

hyst[0]=0; hyst[1]=0; hyst[2]=0.0098; hyst[3]=0.0196; hyst[4]=0.0489; hyst[5]=0.0879; hyst[6]=0.0684; hyst[7]=0.0489; hyst[8]=0.0196; hyst[9]=0.0098; hyst[10]=0; hyst[11]=0; hyst[12]=0; hyst[13]=0; hyst[14]=0; hyst[15]=-0.0195; hyst[16]=-0.0488; hyst[17]=-0.0391; hyst[18]=-0.0195; hyst[19]=0; hyst[20]=0; 

当我尝试:

  public void plotHysteresis() { int j=0; int i=0; XYSeries series1 = new XYSeries("Before Treatment"); // DefaultCategoryDataset series1 = new DefaultCategoryDataset(); for(i=0;i<6;i++) { series1.add(j,hyst[i]); logTextArea.append(Integer.toString(j) +" : " +Double.toString(hyst[i])+"\n"); j=j+5; } j=j-5; for(;i<11;i++) { j=j-5; series1.add(j,hyst[i]); logTextArea.append(Integer.toString(j) +" : " +Double.toString(hyst[i])+"\n"); } for(;i<16;i++) { j=j-5; series1.add(j,hyst[i]); logTextArea.append(Integer.toString(j) +" : " +Double.toString(hyst[i])+"\n"); } for(;i<21;i++) { j=j+5; series1.add(j,hyst[i]); logTextArea.append(Integer.toString(j) +" : " +Double.toString(hyst[i])+"\n"); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); JFreeChart chart = ChartFactory.createXYAreaChart( "Hysteresis Plot", // chart title "Pounds (lb)", // x axis label "Distance (inches)", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); ChartPanel frame = new ChartPanel(chart); frame.setVisible(true); frame.setSize(plotPanel.getWidth(),plotPanel.getHeight()); plotPanel.add(frame); plotPanel.repaint(); } 

它给了我以下结果:

在此处输入图像描述

如果我使用:

  JFreeChart chart = ChartFactory.createXYLineChart( "Hysteresis Plot", // chart title "Pounds (lb)", // x axis label "Distance (inches)", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); 

我给:

在此处输入图像描述

我需要一个滞后图,看起来像: 在此处输入图像描述

我猜不同之处在于连接点的方式。 请指导如何使用jFreeChart获得所需的磁滞回线,然后如何计算所包含的区域。

谢谢

如何更改线条颜色以及表示数据点的符号。 我希望他们所有人都是统一的。

看来你已经确定了JFreeChart的观点。 综合其他一些评论,

  • 您可以通过提供DrawingSupplier使您的几个系列的颜色和形状均匀,如此处所示和此处所示。

  • 您可以将系列组合到GeneralPath并估计此处概述的区域。