Search code examples
javajfreechart

Change a shape of points of XYPlot series


I want to set a shape of points as a circle. This is how I do it:

Shape shape  = new Ellipse2D.Double(-5,-5,5,5);
renderer.setSeriesShape(0,  shape);

Then I get the following result:

enter image description here

Circles are slightly shifted. I tried to change (-5,-5,5,5) in order to center circles according to the line, but nothing has worked. What is the right way to center the circles?


Solution

  • Note that the Ellipse2D boundary includes the upper-left corner's x and y coordinates, as well as width and height. You probably want something like this:

    Shape shape  = new Ellipse2D.Double(-5, -5, 10, 10);
    

    A related examples is examined here, as noted in the response to this comment.