HeatMap with String values on axes

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
TEJASC
Posts: 10
Joined: Fri Mar 14, 2014 2:51 pm
antibot: No, of course not.

HeatMap with String values on axes

Post by TEJASC » Wed Apr 23, 2014 8:17 am

Can I have a HeatMap in JFree similar to this.

Which dataset should I use? I tried using DefaultHeatMapDataset and DefaultXYZDataset but they supports only numeric values on its axes and not String values.

Can I use DefaultCategoryDataset to implement HeatMap?

Suggestions are appreciated.

Thanks in advance.

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

Re: HeatMap with String values on axes

Post by david.gilbert » Thu Apr 24, 2014 1:55 pm

It's not ideal, but you could try the SymbolAxis class (which displays strings in place of integer values).

A better approach (but requiring a lot more coding) would be to store the data in a CategoryDataset (it perfectly matches this numeric table structure) then create a new plot class (it could be called GridPlot or TablePlot) that has ordinal axes (CategoryAxis) for both the x-axis and the y-axis. A renderer for this plot would use the row and column keys to lookup the axes for the coordinates of the cell to be rendered, then "paint" this cell. The existing PaintScale code (LookupPaintScale) could be reused to determine the color used for the fill. The item labeling mechanism could be copied to display the values.
David Gilbert
JFreeChart Project Leader

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

TEJASC
Posts: 10
Joined: Fri Mar 14, 2014 2:51 pm
antibot: No, of course not.

Re: HeatMap with String values on axes

Post by TEJASC » Fri Apr 25, 2014 11:40 am

Thanks a lot.

I preferred first approach. It works like a charm. :P

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: HeatMap with String values on axes

Post by matinh » Thu Dec 14, 2017 10:41 pm

You can find a complete example, including a SymbolAxis on StackOverflow.

Locked