How to remove outliers(small circle) from Box and Whisker

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
milinda.rana
Posts: 3
Joined: Fri Oct 23, 2015 7:29 pm
antibot: No, of course not.

How to remove outliers(small circle) from Box and Whisker

Post by milinda.rana » Sun Oct 25, 2015 9:25 pm

Im using below code to generate box plot chart. But depend on some values it show small circle without drawing the whisker. I need to show whisker not the small circle. Is it possible to hide circle and show the whisker?

private void createBoxPlotChart(OutputStream out, Object data)
throws Exception {

ChartRenderingInfo info = new ChartRenderingInfo();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] ptsImageBytes = null;

DefaultBoxAndWhiskerCategoryDataset boxAndWhiskerCategoryDS = createBoxAndWhiskerCategoryDataSet();

JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(selectedFlight
+ " - Time on Hold", "Arrival Time (Days)",
"Hold Time (Mins)", boxAndWhiskerCategoryDS, true);


NumberAxis rangeAxis = (NumberAxis) chart.getCategoryPlot()
.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setAutoRangeIncludesZero(true);


CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis();

BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) chart.getCategoryPlot().getRenderer();
//renderer.setFillBox(false);
renderer.setMeanVisible(false);
renderer.setUseOutlinePaintForWhiskers(false);
renderer.setMedianVisible(false);


if(boxAndWhiskerCategoryDS.getRowCount()>8){
domainAxis.setCategoryLabelPositions(CategoryLabelPositions
.createUpRotationLabelPositions(Math.PI / 5.0));
}

chart.getCategoryPlot().setBackgroundPaint(Color.white);
chart.getCategoryPlot().setDomainGridlinePaint(Color.gray);
chart.getCategoryPlot().setRangeGridlinePaint(Color.gray);
chart.getCategoryPlot().setOutlineVisible(false);

BufferedImage pageImage = chart.createBufferedImage(CHART_WIDTH,
CHART_HEIGHT, BufferedImage.TYPE_INT_BGR, info);
ImageIO.write(pageImage, IMAGE_TYPE, baos);
baos.flush();
if (null != baos) {
ptsImageBytes = baos.toByteArray();
}

ImageIO.write(pageImage, IMAGE_TYPE, out);

}

private DefaultBoxAndWhiskerCategoryDataset createBoxAndWhiskerCategoryDataSet()
throws ParseException {


DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

for (String graph : graphList) {

final List<Double> list = new ArrayList<Double>();
for (ereportDto ereportDto : holdTimeRptList) {
if (ereportDto != null && ereportDto.getHoldTime() != 0
&& ereportDto.getGraphTime() != null
&& ereportDto.getGraphTime().equalsIgnoreCase(graph)) {

double medianVal=ereportDto.getGraphHoldEntry()+((ereportDto.getGraphHoldExit()-ereportDto.getGraphHoldEntry())/2);

list.add(new Double(ereportDto.getGraphTimeAt120NM()));
list.add(new Double(ereportDto.getGraphHoldEntry()));
list.add(new Double(medianVal));
list.add(new Double(ereportDto.getGraphHoldExit()));
list.add(new Double(ereportDto.getGraphLandedTime()));

}
}
dataset.add(list, graph, graph);
}



return dataset;

}

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: How to remove outliers(small circle) from Box and Whiske

Post by John Matthews » Tue Oct 27, 2015 5:02 am

Cross-posted here.

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

Re: How to remove outliers(small circle) from Box and Whiske

Post by david.gilbert » Tue Oct 27, 2015 12:59 pm

There is not a flag in the renderer to switch off the drawing of the outlier and farout indicators. It would not be so hard to add one to the BoxAndWhiskerRenderer class...just something along the same lines as the 'medianVisible' flag. I think this would be the most straightforward way to get the result you require.
David Gilbert
JFreeChart Project Leader

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

ge0ffrey
Posts: 20
Joined: Sat Feb 27, 2010 6:44 pm
antibot: No, of course not.

Re: How to remove outliers(small circle) from Box and Whiske

Post by ge0ffrey » Fri Oct 30, 2015 11:55 am

Such a flag (to draw outliers as part of the whiskers) would be welcome for me too.
I am using box and whiskers for OptaPlanner metaheuristic benchmarks and the outliers are not considered ignorable,
instead they are considered very important because they represent risk/opportunity.

In case I want to take a stab at this myself:
Is JFreeChart 1.x on GitHub? If not, svn2git works really nicely :)
(I can't find a link to the sources from the project website, nor a "fork me on github" button.)

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

Re: How to remove outliers(small circle) from Box and Whiske

Post by david.gilbert » Fri Oct 30, 2015 5:09 pm

Sources for 1.0.x are in SVN at Sourceforge still, I'll move that to GitHub sometime since I have all my other code there already:

http://sourceforge.net/p/jfreechart/cod ... .x-branch/
David Gilbert
JFreeChart Project Leader

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

Locked