Showing a line graph with an XYPlot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Robbie Edwards

Showing a line graph with an XYPlot

Post by Robbie Edwards » Fri Mar 07, 2003 7:47 am

Hi guys, I'd like to know how you would produce a line running through a graph with plotted data points on it. Thanks in adance!

David Gilbert

Re: Showing a line graph with an XYPlot

Post by David Gilbert » Sat Mar 08, 2003 1:01 am

What sort of line? A regression line? See the Regression class. A horizontal line marking the average? Try the setRangeMarker(...) method in the XYPlot class (you'll have to calculate the average yourself). Something else?

Regards,

Dave Gilbert

Robbie Edwards

Re: Showing a line graph with an XYPlot

Post by Robbie Edwards » Sat Mar 08, 2003 6:54 am

I'm looking for a regression line. I see how you the Regression class works, but I'm wondering how you would draw that regression line from knowing a and b with the scatterplot data still up there?

David Gilbert

Re: Showing a line graph with an XYPlot

Post by David Gilbert » Mon Mar 10, 2003 9:56 am

There's a demo available with the JFreeChart Developer Guide that:

- uses the Regression class to calculate the regression parameters;
- initialises a Function2D to represent the fitted regression line;
- creates an XYDataset by sampling the Function2D (the sampling method is in the DatasetUtilities class);
- creates an OverlaidXYPlot using the original scatter plot and a line plot.

Ideally, JFreeChart would be able to plot the Function2D directly, but that isn't supported yet.

Regards,

Dave Gilbert

Robbie Edwards

Re: Showing a line graph with an XYPlot

Post by Robbie Edwards » Mon Mar 10, 2003 5:23 pm

Just to be sure, the JFreeChart Developer Guide is the documentation that you buy, correct? Thank you so much for all your help!

Locked