Heat map with numbers in boxes
Heat map with numbers in boxes
I am looking make something like this with numbers in boxes. I did look into JFree APIs and couldn't find one which can get me similar.
1. Display z values in the rectangle x,y boxes along with the colors
2. Define colors low and upper bonds for each row
http://www.highcharts.com/demo/heatmap
1. Display z values in the rectangle x,y boxes along with the colors
2. Define colors low and upper bonds for each row
http://www.highcharts.com/demo/heatmap
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Heat map with numbers in boxes
There isn't a chart like that supported by JFreeChart yet. It would be a good one to add though (unfortunately I'm not likely to find the time to do it in the near future though).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Heat map with numbers in boxes
You can probabaly get quiet close by using the following approach:
1. Stuff your data in a matrix-like dataset. Example here.
2. Replace the two NumberAxes with SymbolAxes that use Strings for the TickLabels instead of Numbers. Example here.
3. Use an XYItemLabelGenerator to show the Numbers as such in the chart. Since a special XYItemLabelGenerator for XYZDatasets is not available, you could use an StandardXYZToolTipGenerator and use the String returned from generateToolTip(XYZDataset dataset, int series, int item) as return value in the generateLabel(XYDataset dataset, int series, int item) method of your new XYItemLabelGenerator. Using an ToolTipGenerator as "backend" for an ItemLabelGenerator is described here.
4. An XYBlockRenderer doesn´t appear to drwa the item labels. You can either add the missing lines to the XYBlockRenderer source, or write a new renderer that extends XYBlockRenderer and overwrites the drawItem method. The missing lines to draw the item labels should be something like
where xx and yy are the coordintaes of the data point in Java2D space, and y1 is the y value of the data pointn in data space.
1. Stuff your data in a matrix-like dataset. Example here.
2. Replace the two NumberAxes with SymbolAxes that use Strings for the TickLabels instead of Numbers. Example here.
3. Use an XYItemLabelGenerator to show the Numbers as such in the chart. Since a special XYItemLabelGenerator for XYZDatasets is not available, you could use an StandardXYZToolTipGenerator and use the String returned from generateToolTip(XYZDataset dataset, int series, int item) as return value in the generateLabel(XYDataset dataset, int series, int item) method of your new XYItemLabelGenerator. Using an ToolTipGenerator as "backend" for an ItemLabelGenerator is described here.
4. An XYBlockRenderer doesn´t appear to drwa the item labels. You can either add the missing lines to the XYBlockRenderer source, or write a new renderer that extends XYBlockRenderer and overwrites the drawItem method. The missing lines to draw the item labels should be something like
Code: Select all
if (isItemLabelVisible(series, item)) {
drawItemLabel(g2, orientation, dataset, series, item, xx, yy,
(y1 < 0.0));
}
Re: Heat map with numbers in boxes
It looks like createHeatMapImage() in org.jfree.data.general.HeatMapUtilities could easily be modified to do both of these tasks.1. Display z values in the rectangle x,y boxes along with the colors
2. Define colors low and upper bonds for each row
Re: Heat map with numbers in boxes
@ paradoxoff ,
Thanks for your detailed inputs and the approach works fine. Could you please suggest for the 2nd requirement? It is not a standard heat map as the low and high colors are decided based on low and high values for each row.
Lets say,
row 1 has values from 0 to 10, and min value 0->Red to max 10->Green
row 2 has values from 5 to 18, and min value 5->Red to max 18->Green
...
Any suggestions will be great help.
Thanks for your detailed inputs and the approach works fine. Could you please suggest for the 2nd requirement? It is not a standard heat map as the low and high colors are decided based on low and high values for each row.
Lets say,
row 1 has values from 0 to 10, and min value 0->Red to max 10->Green
row 2 has values from 5 to 18, and min value 5->Red to max 18->Green
...
Any suggestions will be great help.
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Heat map with numbers in boxes
If you really need to implement row-specific min/max values, then use 1 dataset per row. All x values for a specific row will have the same x value. Then, use individual XYBlockRenderer and PaintScales for your rows.
Re: Heat map with numbers in boxes
Your inputs are very helpful and all is well. Thank you.
-
- Posts: 1
- Joined: Wed Mar 15, 2017 12:26 pm
- antibot: No, of course not.
Re: Heat map with numbers in boxes
Hi, I need the same heatmap that you have explained. Could you tell me how did you create it at last? Could anybody give me an example to create one dataset per row?