How to put a Trendline on a Histogram ?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
abinashparija
Posts: 8
Joined: Fri May 15, 2009 1:07 pm

How to put a Trendline on a Histogram ?

Post by abinashparija » Fri Jul 10, 2009 11:02 am

I m doing histograms by using the following code

SimpleHistogramDataset dataset = new SimpleHistogramDataset("Series 1");
SimpleHistogramBin bin1 = new SimpleHistogramBin(5.2756, 10.2756, true, false);
SimpleHistogramBin bin2 = new SimpleHistogramBin(10.2756, 15.2756, true, false);
SimpleHistogramBin bin3 = new SimpleHistogramBin(15.2756, 20.2756, true, false);
SimpleHistogramBin bin4 = new SimpleHistogramBin(20.2756, 25.2756, true, false);
SimpleHistogramBin bin5 = new SimpleHistogramBin(25.2756, 30.2756, true, false);
SimpleHistogramBin bin6 = new SimpleHistogramBin(30.2756, 35.2756, true, false);
SimpleHistogramBin bin7 = new SimpleHistogramBin(35.2756, 40.2756, true, false);
SimpleHistogramBin bin8 = new SimpleHistogramBin(40.2756, 45.2756, true, false);
SimpleHistogramBin bin9 = new SimpleHistogramBin(45.2756, 50.2756, true, false);
SimpleHistogramBin bin10 = new SimpleHistogramBin(50.2756, 55.2756, true, false);
// set the bin counts manually (an alternative is to use the
// addObservation() or addObservations() methods)

// bin1.accepts(4);
bin1.setItemCount(4*5);
bin2.setItemCount(17*5);
bin3.setItemCount(7*5);
bin4.setItemCount(9*5);
bin5.setItemCount(8*5);
bin6.setItemCount(4*5);
bin7.setItemCount(1*5);
bin8.setItemCount(5*5);
bin9.setItemCount(4*5);
bin10.setItemCount(1*5);


dataset.addBin(bin1);
dataset.addBin(bin2);
dataset.addBin(bin3);
dataset.addBin(bin4);
dataset.addBin(bin5);
dataset.addBin(bin6);
dataset.addBin(bin7);
dataset.addBin(bin8);
dataset.addBin(bin9);
dataset.addBin(bin10);
dataset.setAdjustForBinSize(true);


IN this code i want some thing

1>I want to put a trendline as we can do on erxcel.
Actually i am doin this plot for normality test and all.
So i need a smoth trend line on the histogramee

Please help some body .
Its urgent

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

Re: How to put a Trendline on a Histogram ?

Post by david.gilbert » Fri Jul 10, 2009 11:20 am

abinashparija wrote:Its urgent
It's not urgent to me. There are ways that you could make it so, but these involve $$$. Ah, not *that* urgent.

JFreeChart provides a lot of flexibility to overlay one dataset over another, and also to choose the type of rendering for each dataset. All you have to do is add a second dataset and a second renderer to your XYPlot. I'm not going to write the code for you. That's what you are being paid to do.
David Gilbert
JFreeChart Project Leader

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

Locked