Customising error bars

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Damien_Segransan
Posts: 2
Joined: Wed Nov 29, 2006 10:13 pm
Location: Geneva
Contact:

Customising error bars

Post by Damien_Segransan » Wed Nov 29, 2006 10:40 pm

Hi,
Does anyone know how to customize a chart with error bars?

I am currently making charts based on XYErrorRendererDemo1.java.
My data have small error bars and their range (in Y) is large so the default parameters of XYErrorRendererDemo1 are not satisfactory :x.

I have 3 questions :

1> Is it possible to change the size, shape and color of the dot for a given time serie?

2> Is it possible to remove the tiny horizonal segment at the top of the y-error bar ? and to do the same with the x-error bar?

3> Is it possible to change the width of the error bars?

Thanks,

Damien

pkubanek
Posts: 3
Joined: Tue Jun 27, 2006 6:21 pm

Post by pkubanek » Fri Dec 01, 2006 3:48 pm

Hi,

I provided XY patch. I'm as well unhappy with small horizontal and vertical lines, but I cannot find better solution.

> 1> Is it possible to change the size, shape and color of the dot for a given time serie?

You mean central dot? It should be possible, it's setSeriesShape(i, shape) method of XYErrorBarRender. I can add method for color as well if you would like to have one..

> 2> Is it possible to remove the tiny horizonal segment at the top of the y-error bar ? and > to do the same with the x-error bar?

No. Should I add an option for that? I did not like it either.

> 3> Is it possible to change the width of the error bars?

What do you mean by width? Line width? Edge line width?

Petr Kubanek
ISDC, Versoix

Damien_Segransan
Posts: 2
Joined: Wed Nov 29, 2006 10:13 pm
Location: Geneva
Contact:

Post by Damien_Segransan » Fri Dec 01, 2006 10:18 pm

Thanks Petr for your explantions. My figure looks great now !! :-)

To summarise my email exchange with Petr, here is how I did proceed
to customise my graph and error bars.


XYErrorRenderer renderer = new XYErrorRenderer();

renderer.setCapLength(0.02); //that reduces the size of the top and side segment

renderer.setSeriesShape(0, new Ellipse2D.Double(-1.5, -1.5, 3.0, 3.0));//The markers are small filled disks

renderer.setSeriesPaint(0, Color.blue);//The markers and their error bars are blue


Different marker type can be chosen with :
renderer.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));
renderer.setSeriesShape(0, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0));
renderer.setSeriesShape(0, ShapeUtilities.createDiamond(4.0f));

Garfke
Posts: 5
Joined: Tue Sep 29, 2009 10:23 am
antibot: No, of course not.

Re:

Post by Garfke » Tue Sep 29, 2009 11:14 am

Damien_Segransan wrote:Thanks Petr for your explantions. My figure looks great now !! :-)

To summarise my email exchange with Petr, here is how I did proceed
to customise my graph and error bars.


XYErrorRenderer renderer = new XYErrorRenderer();

renderer.setCapLength(0.02); //that reduces the size of the top and side segment

renderer.setSeriesShape(0, new Ellipse2D.Double(-1.5, -1.5, 3.0, 3.0));//The markers are small filled disks

renderer.setSeriesPaint(0, Color.blue);//The markers and their error bars are blue


Different marker type can be chosen with :
renderer.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));
renderer.setSeriesShape(0, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0));
renderer.setSeriesShape(0, ShapeUtilities.createDiamond(4.0f));
Is it possible to change the width of the error bar stroke on a series basis?

Calling

Code: Select all

errorRenderer.setErrorStroke(new BasicStroke(1f));
gives me the strange exception :

Code: Select all

java.lang.NoSuchMethodError: org.jfree.chart.renderer.xy.XYErrorRenderer.setErrorStroke(Ljava/awt/Stroke;)V
Is this the way to change the width of the errorbar?

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

Re: Re:

Post by david.gilbert » Tue Sep 29, 2009 8:48 pm

Garfke wrote:Calling

Code: Select all

errorRenderer.setErrorStroke(new BasicStroke(1f));
gives me the strange exception :

Code: Select all

java.lang.NoSuchMethodError: org.jfree.chart.renderer.xy.XYErrorRenderer.setErrorStroke(Ljava/awt/Stroke;)V
Is this the way to change the width of the errorbar?
That would be a strange exception if you are using JFreeChart 1.0.13, but not if you are using some earlier version which doesn't have that method defined.
David Gilbert
JFreeChart Project Leader

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

Garfke
Posts: 5
Joined: Tue Sep 29, 2009 10:23 am
antibot: No, of course not.

Re: Re:

Post by Garfke » Tue Sep 29, 2009 9:55 pm

david.gilbert wrote:
Garfke wrote:Calling

Code: Select all

errorRenderer.setErrorStroke(new BasicStroke(1f));
gives me the strange exception :

Code: Select all

java.lang.NoSuchMethodError: org.jfree.chart.renderer.xy.XYErrorRenderer.setErrorStroke(Ljava/awt/Stroke;)V
Is this the way to change the width of the errorbar?
That would be a strange exception if you are using JFreeChart 1.0.13, but not if you are using some earlier version which doesn't have that method defined.
I use version 1.0.13 : otherwise I should get a compile-error?

Garfke
Posts: 5
Joined: Tue Sep 29, 2009 10:23 am
antibot: No, of course not.

Re: Re:

Post by Garfke » Tue Sep 29, 2009 9:55 pm

david.gilbert wrote:
Garfke wrote:Calling

Code: Select all

errorRenderer.setErrorStroke(new BasicStroke(1f));
gives me the strange exception :

Code: Select all

java.lang.NoSuchMethodError: org.jfree.chart.renderer.xy.XYErrorRenderer.setErrorStroke(Ljava/awt/Stroke;)V
Is this the way to change the width of the errorbar?
That would be a strange exception if you are using JFreeChart 1.0.13, but not if you are using some earlier version which doesn't have that method defined.
I use version 1.0.13 : otherwise I should get a compile-error?

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

Re: Customising error bars

Post by david.gilbert » Tue Sep 29, 2009 9:56 pm

Maybe you compile with 1.0.13 then run with another version. You wouldn't be the first.
David Gilbert
JFreeChart Project Leader

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

Garfke
Posts: 5
Joined: Tue Sep 29, 2009 10:23 am
antibot: No, of course not.

Re: Customising error bars

Post by Garfke » Wed Sep 30, 2009 2:57 pm

david.gilbert wrote:Maybe you compile with 1.0.13 then run with another version. You wouldn't be the first.
you're probably right... :oops:

I never downloaded another version because i never used JFreeChart before... but... for my new project I use some classes from another project in eclipse. I checked that other project out of SVN and I now found that that other project contains certain classes that make charts and an older version was in the lib of that project in SVN...

Stupid eclipse : it should give precedence to libs in the main project...

Anyway, thanks for the hint!

Locked