HeatMap how to plot negative values with different color

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
dabd
Posts: 1
Joined: Tue Jun 26, 2012 9:43 pm
antibot: No, of course not.

HeatMap how to plot negative values with different color

Post by dabd » Tue Jun 26, 2012 9:46 pm

Given a dataset that has some negative values how do I plot them with distinguishable colors from small positive values?
The library that I am using seems to be using org.jfree.chart.renderer.LookupPaintScale to get the color scale.

I would appreciate if someone showed me an example that uses colors from blue up to red with negative values in shades of blue and positive values in shades of yellow->orange->red.

Thanks.

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

Re: HeatMap how to plot negative values with different color

Post by John Matthews » Thu Jun 28, 2012 4:16 am

This example constructs a List<Color> for the entire spectrum using Color.getHSBColor(), but you can choose a smaller range of hues. Once you have the list, you can add them to an instance of LookupPaintScale. Use a contrasting Color for the defaultPaint, which is used for negative values. Alternatively, you may need to shift values or use linear interpolation to get the desired Color based on the given data value in a custom implementation of PaintScale.

Locked