Category plot with error bars

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
J.
Posts: 17
Joined: Fri Jun 27, 2008 5:30 pm

Category plot with error bars

Post by J. » Thu Jul 03, 2008 10:12 am

I need a category plot displaying only a few data items which must be updatable, looking like this: http://i7.photobucket.com/albums/y260/- ... orbars.jpg

I created the above chart using DefaultStatisticalCategoryDataset which just about works perfectly. However, I cannot figure out a suitable way to update the dataset and thus the chart. Say on that chart I want to update Group 2s data, I've tried removing the relevant data from the dataset and adding in new data for Group 2 but this means the X axis is now unordered (Group 1...Group 3...Group 2).

Alternatively I tried implementing it using DefaultCategoryDataset. This allows me to edit and update the mean values on my chart perfectly through the setValue method but I can't figure out how to add (updatable) error bars to this chart!

If DefaultStatisticalCategoryDataset had setMean and setStDv methods that would be perfect! Can anyone see how I can be both updatable and include error charts? Or perhaps an alternative way of updating my DefaultStatisticalCategoryDataset which would keep the order of items on the x axis?

Thanks! I did do a good search through the forums but couldn't find anything exactly like this.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Category plot with error bars

Post by paradoxoff » Thu Jul 03, 2008 10:35 am

J. wrote: I created the above chart using DefaultStatisticalCategoryDataset which just about works perfectly. However, I cannot figure out a suitable way to update the dataset and thus the chart. Say on that chart I want to update Group 2s data, I've tried removing the relevant data from the dataset and adding in new data for Group 2 but this means the X axis is now unordered (Group 1...Group 3...Group 2).

Alternatively I tried implementing it using DefaultCategoryDataset. This allows me to edit and update the mean values on my chart perfectly through the setValue method but I can't figure out how to add (updatable) error bars to this chart!

If DefaultStatisticalCategoryDataset had setMean and setStDv methods that would be perfect!
Have you tried to add the men and stddev values without removing the old data first, e. g. just call

Code: Select all

DefaultStatisticalCategoryDataset.add(double mean, double standardDeviation, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
DefaultStatisticalCategoryDataset stores its data internally in an instance of KeyedObjects2D. DefaultStatisticalCategoryDataset.add(double mean, double standardDeviation, java.lang.Comparable rowKey, java.lang.Comparable columnKey) calls KeyedObjects2D.addObject(item, rowKey, columnKey) ("item" is an instance of MeanAndStandardDeviation) which will overwrite an object residing at the same (rowKey, columnKey) position. I expect that your data will be updated and the order will be kept.

J.
Posts: 17
Joined: Fri Jun 27, 2008 5:30 pm

Post by J. » Thu Jul 03, 2008 11:06 am

Just what I needed, thanks very much!

Locked