Changing the color in a ScatterPlot does not work...

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Harry Plotter ;-)
Posts: 12
Joined: Thu Aug 04, 2005 2:56 pm
Location: Oldenburg - Germany

Changing the color in a ScatterPlot does not work...

Post by Harry Plotter ;-) » Tue Aug 30, 2005 2:19 pm

Hi everyone,

I have a problem concerning the change of the color with adding an XYDataset to the Chart.

Here's my code snippet:

Code: Select all

        this.xyDataset = new XYSeriesCollection(series);
        this.xyDataset2 = new XYSeriesCollection(series2);

        plot.getXYPlot().setDataset(0,this.xyDataset);
        plot.getXYPlot().setDataset(1,this.xyDataset2);
        
        plot.getXYPlot().getRenderer().setSeriesPaint(0,Color.GREEN);
        plot.getXYPlot().getRenderer().setSeriesPaint(1,Color.GRAY);

        if(plot.getXYPlot().getRenderer(0).getSeriesPaint(0).equals(Color.GREEN))
        	System.out.println("Color is green");
        else
        	System.out.println(plot.getXYPlot().getRenderer(0).getSeriesPaint(1));

        if(plot.getXYPlot().getRenderer(0).getSeriesPaint(1).equals(Color.GRAY))
        	System.out.println("Color is gray");
        else
        	System.out.println(plot.getXYPlot().getRenderer(0).getSeriesPaint(1));
The System-out statements print out the expected results but anyway, the color of the second series is the same as the first.

Does anybody see what I'm doing wrong?

Thanks for your help.

Peter

pmlb
Posts: 31
Joined: Thu Aug 25, 2005 5:18 pm
Location: France

Post by pmlb » Tue Aug 30, 2005 2:27 pm

You have two datasets. Each dataset has only one series. I think you should use two renderers, one for each dataset, then assign different colors to series 0 of each renderer.
Pierre-Marie

Harry Plotter ;-)
Posts: 12
Joined: Thu Aug 04, 2005 2:56 pm
Location: Oldenburg - Germany

Post by Harry Plotter ;-) » Tue Aug 30, 2005 2:34 pm

thanks a lot, that solved the problem.

Greetings,
Peter

Locked