Am I using Box Plot correctly?

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Jesse
Newbie
Newbie
Posts: 28
Joined: Tue Mar 11, 2008 12:00 am
Location: Austin, TX

Am I using Box Plot correctly?

Post by Jesse » Thu Jun 19, 2008 3:49 am

Here is a very simple use of Box plot.

Why is the whisker showing up inside the box?

Am I doing something wrong? It seems like the bottom whisker is wrapped up and ending on the median.

Code: Select all

package com.amd.ngeda.chart.teechart;

import javax.swing.JFrame;

import com.steema.teechart.TChart;
import com.steema.teechart.drawing.Color;
import com.steema.teechart.styles.Box;

public class TestBrokenBox {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		JFrame frame = new JFrame("HelloWorldSwing");
		TChart teeChart = new TChart();
		teeChart.setBackColor(new Color(255, 255, 255));
		teeChart.getAspect().setView3D(false);

		Box box = new Box(teeChart.getChart());
		double[] yvals = new double[] { 9, 9, 9, 8, 8, 8, 7, 7, 6, 6 };

		box.getYValues().setCount(yvals.length);
		box.getYValues().setValues(yvals);
		frame.getContentPane().add(teeChart);

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);

	}
}

Jesse
Newbie
Newbie
Posts: 28
Joined: Tue Mar 11, 2008 12:00 am
Location: Austin, TX

Post by Jesse » Thu Jun 19, 2008 4:02 am

I went and found some more data on the net to compare results. The data that I found was a tutorial on how to create a box plot. I tried the data and it worked. I have been thinking to myself that there is a bug in TChart relating to how tightly the data is clustered. I know... I'm "grasping at straws".

Anyway, I noticed that the test data in this example was SORTED. Sure enough, I get different results when the data is sorted.

Huh? So, do we have to sort the data before using it?!?! Is this the solution?

Are there any other charts types that have a similar requirement?
---
Jesse Steinfort

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 19, 2008 8:44 am

Hi Jesse,

The internal calculations (median, percentiles) assume ordered values i.e. you must order the values before you add them to box series.

No, I can't think of other series that need sorted values.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Jesse
Newbie
Newbie
Posts: 28
Joined: Tue Mar 11, 2008 12:00 am
Location: Austin, TX

Post by Jesse » Thu Jun 19, 2008 2:30 pm

Thanks. Please update your documentation for the next guy. :-)

Post Reply