Changing the marks on a scatter plot?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Mike Keller
Posts: 23
Joined: Mon Jul 06, 2009 12:59 pm

Changing the marks on a scatter plot?

Post by Mike Keller » Mon Jul 27, 2009 4:33 pm

I have a scatterplot that, right now, displays rectangles. Is there a way to change this to smaller dots? I can't seem to find any information regarding it.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Changing the marks on a scatter plot?

Post by david.gilbert » Mon Jul 27, 2009 4:44 pm

If you are using the XYLineAndShapeRenderer (it is the default) then you can:

(1) Call the setSeriesShape(...) method to change the shape that is displayed;

(2) Replace the renderer with an XYDotRenderer.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Mike Keller
Posts: 23
Joined: Mon Jul 06, 2009 12:59 pm

Re: Changing the marks on a scatter plot?

Post by Mike Keller » Mon Jul 27, 2009 4:55 pm

Thanks, that's exactly the answer I needed!

Edit: Except one thing...how do I change the renderer used?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Changing the marks on a scatter plot?

Post by david.gilbert » Mon Jul 27, 2009 5:02 pm

Code: Select all

XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new XYDotRenderer());
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Mike Keller
Posts: 23
Joined: Mon Jul 06, 2009 12:59 pm

Re: Changing the marks on a scatter plot?

Post by Mike Keller » Mon Jul 27, 2009 5:03 pm

Oh, that's simple. You thought of everything!

DeO
Posts: 8
Joined: Thu Jul 23, 2009 4:13 pm
antibot: No, of course not.

Re: Changing the marks on a scatter plot?

Post by DeO » Mon Jul 27, 2009 7:13 pm

Is there a way to set or even get the current active shape of a series?
Are there DefaultShapes as like Color.BLUE which can be used?

hbro
Posts: 5
Joined: Mon May 18, 2009 1:27 pm
Location: Retie, Belgium

Re: Changing the marks on a scatter plot?

Post by hbro » Mon Jul 27, 2009 8:25 pm

Check the ShapeUtilities API Reference

http://www.jfree.org/jcommon/api/org/jf ... ities.html
-HBro

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Changing the marks on a scatter plot?

Post by david.gilbert » Mon Jul 27, 2009 9:08 pm

DeO wrote:Is there a way to set or even get the current active shape of a series?
Are there DefaultShapes as like Color.BLUE which can be used?
If you rely on the defaults, they are assigned to the renderer the first time the chart is drawn, so it is tricky to find out the shapes until after the chart has been rendered (the renderer's getSeriesShape(int) method will return null prior to the first rendering). You *could* call lookupSeriesShape(int) which will do the default auto-populate for the shape if it hasn't already been done or disabled.

Color.BLUE is not a shape, so I'm not quite sure what you meant by the second question.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked