JFreeChart Scatter + Line

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
MidKnight
Posts: 3
Joined: Tue Sep 15, 2020 5:27 pm
antibot: No, of course not.
Contact:

JFreeChart Scatter + Line

Post by MidKnight » Sat Sep 19, 2020 4:24 pm

I've been learning JFreeChart lately, and came across a scatter plot in this tutorial series. Now, I understand how to create and modify it, but I'm curious if there is a way to run a line through it as well.

Like a combination of both the line and scatter graphs. Is something like this possible?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: JFreeChart Scatter + Line

Post by John Matthews » Sun Sep 20, 2020 3:09 pm

Yes. If you're using a ChartFactory to create your scatter plot, note that it instantiates an XYLineAndShapeRenderer. One approach then is to add two series, one for the shapes and one for the line, setting the latter's visibility properties as seen here. Alternatively, look among the org.jfree.chart.annotations, e.g. XYLineAnnotation.

Locked