gpt4 book ai didi

java - Jfree图表xy线实现

转载 作者:太空宇宙 更新时间:2023-11-04 08:36:44 24 4
gpt4 key购买 nike

我想在一个数据集中绘制 4 条线,但我不能。任何人都可以告诉我 jfree 中需要哪些库以及如何在 1 个图表中实现它们

 public void visualise(){
//visualise data
XYSeries series = new XYSeries("Membrane mVolt");
XYSeries series2 = new XYSeries("potassium_channel_n_gate_n");
XYSeries series3 = new XYSeries("sodium_channel_h_gate_h");
XYSeries series4 = new XYSeries("sodium_channel_m_gate_m");
//add data to charts
for(int l=0;l<301;l++){
series.add(tData[l], YData[0][l]);
series2.add(tData[l], YData[1][l]);
series3.add(tData[l], YData[2][l]);
series4.add(tData[l], YData[3][l]);
}
//create lines
XYDataset xyDataset = new XYSeriesCollection(series);
XYDataset xyDataset2 = new XYSeriesCollection(series2);
XYDataset xyDataset3 = new XYSeriesCollection(series3);
XYDataset xyDataset4 = new XYSeriesCollection(series4);

//visualize
JFreeChart chart = ChartFactory.createXYLineChart("Membrane", "time","data",xyDataset, PlotOrientation.VERTICAL, true, true, false);
JFreeChart chart2 = ChartFactory.createXYLineChart("Potassium Channel n", "time""data",xyDataset2,PlotOrientation.VERTICAL, true, true, false);
JFreeChart chart3 = ChartFactory.createXYLineChart("Sodium Channel h", "time","data",xyDataset3, PlotOrientation.VERTICAL, true, true, false);
JFreeChart chart4 = ChartFactory.createXYLineChart("Sodium Channel m", "time", "data",xyDataset4,
PlotOrientation.VERTICAL, true, true, false);
//open window
ChartFrame frame1=new ChartFrame(" ",chart);
ChartFrame frame2=new ChartFrame(" ",chart2);
ChartFrame frame3=new ChartFrame(" ",chart3);
ChartFrame frame4=new ChartFrame(" ",chart4);

//make window
frame1.setVisible(true);
frame1.setSize(900,900);
frame2.setVisible(true);
frame2.setSize(900,900);
frame3.setVisible(true);
frame3.setSize(900,900);
frame4.setVisible(true);
frame4.setSize(900,900);
}

最佳答案

这个example演示如何将多个系列添加到 DefaultXYDataset .

关于java - Jfree图表xy线实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6184122/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com