How to set width of BoxAndWhisker item?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
nimowy
Posts: 19
Joined: Fri Jan 25, 2008 10:16 pm

How to set width of BoxAndWhisker item?

Post by nimowy » Thu Jan 31, 2008 8:28 pm

Hi folks,

I am trying to set the width of my BoxAndWhisker items - they are too fat.

I tried this, but it has no effect:
BoxAndWhiskerRenderer bRenderer = (BoxAndWhiskerRenderer) plot.getRenderer();
bRenderer.setSeriesFillPaint(0, Color.green);
bRenderer.setItemMargin(0.5);

I'm using jfreechart-1.0.9. The color doesn't change either.

The chart I'm making is an overlaid chart, so I add a line chart on top of it, so people can see where they fall in the norms, but such fat boxes look bad...

nimowy
Posts: 19
Joined: Fri Jan 25, 2008 10:16 pm

Post by nimowy » Mon Feb 04, 2008 5:27 pm

I figured out the problem. SetMargin is actually using a percentage of the available space for bars/boxes. And it's a 0 to 1 percentage, so .5 was way too big. The greater the margin, the smaller the bars/boxes. Also, you don't want to set the margin on the item, that's actually the wrong one. You want to set the margin on the axis.

Code: Select all

CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLowerMargin(0.15);
domainAxis.setUpperMargin(0.15);
domainAxis.setCategoryMargin(0.25);
Hope that helps someone....

skaufman1974
Posts: 1
Joined: Sun Apr 06, 2008 1:07 am

Trouble scaling a single BoxAndWhisker plot

Post by skaufman1974 » Sun Apr 06, 2008 4:49 pm

Hi,
Not sure this is 100% related, but I'm trying to render a single BoxAndWhisker plot (single data set - 1 series and 1 category). The width of the Box plot is huge - it takes up the width of the whole window. The median dot is also huge. Is there a way to adjust this? Also, in your example code, what type of object is "plot"?
Thanks very much!

Locked