non-linear colorbar

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jane
Posts: 14
Joined: Wed Jun 25, 2008 7:16 pm

non-linear colorbar

Post by Jane » Tue Aug 25, 2009 5:05 pm

Hello,

I'm using MyBlockRenderer and XYPlot to make contour plots. The problem I have is that the values of the data are not uniformly distributed. For example, I may have less than 5% of extreme values that are way larger or smaller than the others. Consequently, when I use the PaintScaleLegend to draw the colorbar, the colorbar is filled with the values that rarely seen in the contour plot. So, I'd like to know if there is a way to make a nonlinear colorbar.

Thanks in advance,
Jane

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

Re: non-linear colorbar

Post by paradoxoff » Wed Aug 26, 2009 9:35 pm

Have you tried to set a LogAxis as ValueAxis for the PaintScaleLegend?

Jane
Posts: 14
Joined: Wed Jun 25, 2008 7:16 pm

Re: non-linear colorbar

Post by Jane » Thu Aug 27, 2009 12:20 pm

No. That's because I have both positive and negative values. About 5% of values are between -155 and -20, 3% between +20 and +25, and the rest are in between -20 and +20.

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

Re: non-linear colorbar

Post by paradoxoff » Thu Aug 27, 2009 8:08 pm

what type of PaintScale are you using? For your case, a LookupPaintScale could be a good idea. You could also create your own implementation from scratch.

Jane
Posts: 14
Joined: Wed Jun 25, 2008 7:16 pm

Re: non-linear colorbar

Post by Jane » Fri Aug 28, 2009 5:48 pm

Hello Paradoxoff,

First of all, thank you very much for your interest.

Yes, I did use the LookupPaintScale. I set most of the colors to the range within +-20. The range outside was assigned to only a few colors.
The plot looks ok, but the ticks on the colorbar are evenly spaced out. Therefore, large portion of the colorbar is devoted to the small fraction
of the data points. Did I explain clear enough? I wish I know how to put my plot here so that you know exactly what I mean.

Do you have any suggestions regarding to the colorbar? Here is part of the code I used to make it:

LookupPaintScale scale = new LookupPaintScale(imin, imax, Color.white);
scale.add( contourValue1, new Color( r[0], g[0], b[0] );
scale.add..............
.........................
NumberAxis scaleAxis = new NumberAxis("My color scale");
PaintScaleLegend legend = new PaintScaleLegend(scale, scaleAxis);
...............................
..............................
chart.addSubtitle(legend);

Jane
Posts: 14
Joined: Wed Jun 25, 2008 7:16 pm

Re: non-linear colorbar

Post by Jane » Mon Aug 31, 2009 7:29 pm

Perhaps, one way to do this is

1. Re-assign values to my dataset
For example, set anything less than -20 to 1; set values between -5 and -3 to 2; .....
2. Make the contour plot
3. Make the colorbar with PaintScaleLegend();
4. Somehow erase the tickmark labels for the colorbar
5. Label the tickmarks with the original values for the contours (ie. -20, -5, -3 etc.)

Any other suggestions:?:

Locked