Page 1 of 1

Am I using Box Plot correctly?

Posted: Thu Jun 19, 2008 3:49 am
by 7667592
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);

	}
}

Posted: Thu Jun 19, 2008 4:02 am
by 7667592
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?

Posted: Thu Jun 19, 2008 8:44 am
by narcis
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.

Posted: Thu Jun 19, 2008 2:30 pm
by 7667592
Thanks. Please update your documentation for the next guy. :-)