Page 1 of 1

Clarification on the box chart graphic

Posted: Wed Aug 01, 2007 4:41 pm
by 9348135
Hello,

First I would like to thank Narcis Calvet for responding to my question in the teechart7.delphi news group about labels for the marks.

Second, I would like to know what the different parts of the box chart mean and how to change them. I am afraid I am not familiar with the terms inner and outer fence.

I would like the box ends to be at the quartile values of the distribution, which they appear to be. I would like the whisker ends to represent the 5th percentile and 95th percentile respectively. I'd also like to be able to change them to the 2.5th and 97.5th percentile.

Thank you for your help. I like the TeeChart but I need to learn to think like it does.

Hardee Mahoney
Washington, DC

Posted: Thu Aug 02, 2007 8:35 am
by narcis
Hi Hardee,

In that case, reading the threads below about box plot may be helpful for you. Those are TeeChart for .NET topics but the same applies to TeeChart VCL.

http://www.teechart.net/support/viewtopic.php?t=2599
http://www.teechart.net/support/viewtopic.php?t=5645

Hope this helps!

Posted: Thu Aug 02, 2007 1:55 pm
by 9348135
Thanks for your response.

But I still don't seem to be able to draw the box plot where the lower whisker end is visually at the 5th percentile and the upper whisker end is at the 95th percentile. From your example you pointed me to, it seems the adjacentpoint properties control the whiskers but I can't get it to change the look of the plot.

Code: Select all

Your example:
// adjacent points are related with whisker lines
                  box1.AdjacentPoint1 = 37; // lower whisker at 37
                  box1.AdjacentPoint3 = 43; // upper whisker at 43 

here is my example

Code: Select all

Box := TBoxSeries.Create;
Box.Clear;

Box.UseCustomValues;

for i := 0 to 99 do
   Box.AddY(i);

Box.AdjacentPoint1 := 10;
Box.AdjacentPoint3 := 90;
Box.RecalcStats;
Box.Position := 0;
Box.ParentChart := Chart1;
Thanks

Hardee Mahoney
Washington, DC

Posted: Thu Aug 02, 2007 2:27 pm
by narcis
Hi Hardee,

Code below displays a Box-Plot here. Can you please test if it works fine at your end?

Code: Select all

uses TeeBoxPlot;

procedure TForm1.FormCreate(Sender: TObject);
var Box: TBoxSeries;
    i: Integer;
begin
  Box := TBoxSeries.Create(self);
  Box.Clear;

  Box.UseCustomValues:=true;

  for i := 0 to 99 do
     Box.AddY(i);

  Box.AdjacentPoint1 := 10;
  Box.AdjacentPoint3 := 90;
  Box.RecalcStats;
  Box.Position := 0;
  Box.ParentChart := Chart1;
end;
Thanks in advance.

Posted: Thu Aug 02, 2007 2:37 pm
by 9348135
It draws a box chart very nicely. But it doesn't change the way the whiskers look. I am hoping the top whisker will have its end at 90 and the bottom one at 10. It looks to me like the top one ends at the max and the bottom at the min.

I am using TChart Pro Version 7.07 in Delphi 7.

Posted: Mon Aug 06, 2007 8:51 am
by narcis
Hi Hardee,

Code below works fine here either using v7 or v8. Can you please test if it works fine at your end?

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var Box: TBoxSeries;
    i: Integer;
begin
  Box := TBoxSeries.Create(self);
  Box.ParentChart := Chart1;
  Box.Position := 0;
  Box.Clear;


  for i := 0 to 99 do
     Box.AddY(i);

  Box.UseCustomValues:=true;
  // If custom values are use, you have to define ALL box plot properties
  // bottom whisker
  Box.AdjacentPoint1 := 10;
  // top whisker
  Box.AdjacentPoint3 := 90;
  // box bounds
  Box.Quartile1 := 25;
  Box.Quartile3 := 75;
  Box.Median := 50;

  // Outliers
  // Mild outliers in (9,20) and (85,91)
  Box.InnerFence1 := 20;
  Box.InnerFence3 := 85;
  // Extreme outliers if <9 or >91
  Box.OuterFence1 := 9;
  Box.OuterFence3 := 91;
end;
Thanks in advance.

Posted: Mon Aug 06, 2007 2:12 pm
by 9348135
Narcis,

Thank you very much for working with me on this.

When you run the code you gave me do you see the whisker ends - the black cross bar at the end of the whisker - appear at 10 and 90? When I run the code they appear at 0 and 99.

I can't understand what I am doing wrong.

Posted: Mon Aug 06, 2007 2:39 pm
by narcis
Hi Hardee,

It's most likely because, as commented out in the example code I posted, when using custom values, you have to define all box plot properties.

Posted: Mon Aug 06, 2007 3:10 pm
by 9348135
Narcis,

Thanks so much for your help. I got it to work by taking out the recalcstats. I swore my code was just like yours, but...

Is this behavior for recalcstats like you expect?

Again, thanks for your help.

Posted: Mon Aug 06, 2007 3:15 pm
by narcis
Hi Hardee,
Thanks so much for your help. I got it to work by taking out the recalcstats. I swore my code was just like yours, but...
I'm glad to hear you got it working.
Is this behavior for recalcstats like you expect?


Yes, RecalcStats recalculates all parameters necessary to draw the box (Median, Quartiles, Inner and Outer points, etc.). This method can be called whenever the box underlying data is changed.