我在Java有点新。
现在,我正在尝试使用JFreeChart绘制XYPlot,其中域轴(X轴)和范围轴(Y轴)包含相同的范围。但不幸的是,滴答单位是不同的!出于这个原因,我尝试使用NumberAxis根据范围轴上的范围和刻度单位在域轴上设置范围和刻度单位。但差异仍然存在。我仍然无法找出为什么会发生这种情况。
我正在附加此绘图的代码。此外,我正在附加问题的屏幕截图以及我真正想要的!请指导我在这里做错了什么...
XYSeriesCollection lineChartDataAD = new XYSeriesCollection();
XYSeries seriesAD = new XYSeries("Real Surface Heights", false, true);
for (int m = 0; m < pt.delayedy.length - 1; m++) {
seriesAD.add((double)pt.delayedy[m], (double)pt.delayedy[m+1]);
}
lineChartDataAD.addSeries(seriesAD);
if (jRadioButton10.isSelected()) { //as it is checkbox2.getState() == true
pt.xaxisAD = pt.yvar+" ("+pt.xvar+") ["+pt.yunit+"]";
pt.yaxisADsupport = String.format("%f", (pt.xspace*pt.delay));
//pt.yaxisAD = pt.yvar +" (i+"+pt.yaxisADsupport+")";
pt.yaxisAD = pt.yvar+" ("+pt.xvar+"+d) ["+pt.yunit+"]";
jLabel44.setText("(Delay (d) = "+pt.yaxisADsupport+" "+pt.xunit+")");
}
else if (jRadioButton11.isSelected()) { //as time series checkbox1.getState() == true
//pt.yaxisAD = pt.yvar +" (i+"+pt.delay+")";
pt.xaxisAD = pt.yvar+" (i) ["+pt.yunit+"]";
pt.yaxisAD = pt.yvar +" (i+d) ["+pt.yunit+"]";
jLabel44.setText("(Delay (d) = "+pt.delay+")");
}
JFreeChart lineChartAD = ChartFactory.createXYLineChart("", pt.xaxisAD, pt.yaxisAD, (XYDataset) lineChartDataAD, PlotOrientation.VERTICAL, false, false, false);
XYPlot plotAD = lineChartAD.getXYPlot();
NumberAxis D = (NumberAxis) plotAD.getDomainAxis();
NumberAxis R = (NumberAxis) plotAD.getRangeAxis();
D.setRange(R.getRange());
D.setTickUnit(R.getTickUnit());
XYLineAndShapeRenderer rendererAD = new XYLineAndShapeRenderer();
问题||的屏幕截图刻度单位不同
所需结果||的屏幕截图两个轴上的刻度单位相同
有只小跳蛙
相关分类