How make a normal distribution using JFreeChart?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
J.
Posts: 17
Joined: Fri Jun 27, 2008 5:30 pm

Post by J. » Sat Jul 19, 2008 9:18 pm

The second series was meant to be vertical. The graph I am trying to achieve is something like this:

http://i7.photobucket.com/albums/y260/- ... fpdftb.gif

My understanding from the earlier posts in this thread was that you were suggesting drawing the curve as the first series, and drawing the vertical line as the second series, and then filling in the area between the series.

Just to explain what I was trying to do before
double f = 2; // point along the X axis where to draw the line
XYSeries fLine = new XYSeries("fLine");
fLine.add(f, 0); // first point in series drawn at value 2 along the bottom of x axis
fLine.add(f, group.getValue(f)); // second point drawn directly above first point (in order to create vertical line) and at the point which intersects with the curve
dataset.addSeries(fLine);

Replacing the code you suggested did not work for me, I just got an IndexOutOfBoundsException exception.

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Post by RichardWest » Sat Jul 19, 2008 9:47 pm

J. wrote:Replacing the code you suggested did not work for me, I just got an IndexOutOfBoundsException exception.
That is because I transposed the x and y values when I transcribed the code by hand. Try:

Code: Select all

XYSeries fLine = new XYSeries("fLine");
fLine.add(0, 0);
fLine.add(2, 0);
dataset.addSeries(fLine);
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

J.
Posts: 17
Joined: Fri Jun 27, 2008 5:30 pm

Post by J. » Sat Jul 19, 2008 9:51 pm

Ah! Sorry, I see what I was doing. I thought I was meant to draw the second line as vertical, rather than horizontal. That makes sense now.

Thanks very much for your help!

Locked