JHeatChart is a simple Java library for generating heat map charts for output as image files or use in GUIs. It is open source under an LGPL license.

Examples

Basic heat map

The following code will produce a very basic heat map saved as a .png file.  Although this is a very simple example, more advanced cases are not much more complex. Simply expand step 2 to set other parameters such as the colour range, title font, axis values or any of the many other configuration options.

// Create some dummy data.
double[][] data = new double[][]{{3,2,3,4,5,6},
                                 {2,3,4,5,6,7},
                                 {3,4,5,6,7,6},
                                 {4,5,6,7,6,5}};

// Step 1: Create our heat map chart using our data.
HeatChart map = new HeatChart(data);

// Step 2: Customise the chart.
map.setTitle("This is my heat chart title");
map.setXAxisLabel("X Axis");
map.setYAxisLabel("Y Axis");

// Step 3: Output the chart to a file.
map.saveToFile(new File("java-heat-chart.png"));

This code should produce the following heat map image. Note that by default the colour range is greyscale, for more interesting images you can use the setHighValueColour(Color) and setLowValueColour(Color) methods.

Basic example heat map



Leave a Comment