我有两个属于同一数据集的XYSeries。第一个系列必须仅显示形状,而第二个系列必须仅显示线条。两者必须具有相同的颜色。有办法吗?
提供一段代码以便更好地理解:
XYSeries series = new XYSeries("S1", false); // autosort disabled
for(int i = 0; i < xValues.length; ++i)
series.add(xValues[i], yValues[i]);
XYSeries series1 = new XYSeries("S2", false);
for(int i = 0; i < xValues.length; ++i)
series1.add(yValues[i], xValues[i]);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
dataset.addSeries(series1);
// create a chart with title, axis labels, tooltips and maybe a legend
JFreeChart chart = ChartFactory.createScatterPlot(title, xLabel, yLabel, dataset,
PlotOrientation.VERTICAL, legend, true, false);
XYPlot plot = (XYPlot) chart.getPlot();
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
renderer.setSeriesLinesVisible(0, true);
renderer.setSeriesShapesVisible(1, false);
renderer.setSeriesLinesVisible(1, true);