Showing a line graph with an XYPlot
Showing a line graph with an XYPlot
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!
Re: Showing a line graph with an XYPlot
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
Regards,
Dave Gilbert
Re: Showing a line graph with an XYPlot
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?
Re: Showing a line graph with an XYPlot
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
- 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
Re: Showing a line graph with an XYPlot
Just to be sure, the JFreeChart Developer Guide is the documentation that you buy, correct? Thank you so much for all your help!