7

I have some numeric data in matrix form, which for the sake of discussion is the values of some function f(x,y) sampled at some discrete grid. This data is, say, in a .csv file or in an .ods (LibreOffice Calc) / .xlsx (Excel) table; of course I can change formats if necessary.

I want to generate a heatmap for this data: A rectangular image which, at each (x,y) position, has color whose intensity is proportional to to some reasonable interpolation of f(x,y) using the sample data.

Now, the Wikipedia page has a bunch of links to software which produces one kind or another of heat maps, but I'm interested in a comparison among them, with respect to:

  • Intuitivity of use
  • Ease of input ingestion
  • Speed
  • Support for infinte-resolution maps
  • Ability to produce output files in various formats
  • Configurability and tweakability (color palettes, value ranges, transforming values with a specified function, generating just the values at the grid points or generating them as overlays, labels etc.))

Also, are there formats which support generating svg's which somehow support heatmaps intrinsically, i.e. using two-variable gradient area coloring?

(I'm secretly hoping for a LibreOffice plugin, but I guess there isn't one.)

Requirements:

  • Libre, Gratis and Open-Source, unless it's some Excel add-on
  • Linux, preferably also Windows

Edit: While I have accepted an answer, other options are still very welcome, especially ones with a GUI.

| improve this question | | | | |
  • Would you accept an HTML or PDF solution? Graph, histogram, or geographical overlay? The more info you can give us, the better answer we can give you. – Mawg says reinstate Monica Mar 2 '17 at 8:33
  • @Mawg: (1) Yes. (2) As an option, sure, but not if I can't avoid it. Just the heatmap please. – einpoklum Mar 2 '17 at 9:03
1

Here's an easier way.

There's a free and open source utility xyz to quickly and conveniently visualize 3-dimensional numeric-data from any CSV file.

It does auto-interpolation on the X, Y dimensions so it works even on partial (non full-grid) data. It allows you to extract any column by name or index from larger data-sets, and has many other options and parameters you can set from the command line. e.g. change title, axis-labels, color-scheme, whether to add contour-lines, and more.

Here's an example output generated from the R-project volcano.csv data-set:

volcano.png auto-generated from the R <code>volcano.csv</code> data-set

Here's another example, showing command line control over the heatmap:

# Use same data-file, with explicit column indexes, no contour-lines
# different color-scheme, use log-scale on the X-axis, and customized
# resolutions on two of the axes
xyz volcano.csv 0 1 2 cl=0 xscale=log \
    xlab='X (log scale)' ylab=Y title='log-squished seismic volcano' \
    cmap=seismic zres=40 xres=50

log-squished volcano image

xyz written in python, using pandas + matplotlib.

xyz is FOSS. The source can be downloaded from my scripts repository on github: https://github.com/arielf/scripts.

Here's a direct link to the raw xyz script

The script provides a usage message when called with no parameters or erroneous ones.

(Full disclosure: I am the author of xyz.)

| improve this answer | | | | |
  • 1
    Thank you for writing this tool. You mentioned it is easier than gnuplot. Can you explain in what sense? – einpoklum Nov 28 '18 at 9:05
  • 1
    It automates most of the work, everything has a default, incl. interpolation, so all you need to generate an image is just provide a data-file and the columns you want to extract/plot. e.g. xyz datafile.csv 0 1 2. It gives you additional control via command line parameters so it is more natural (and I'm pretty familiar with gnuplot) to use directly from the command line, without having to learn a new (even small) language/syntactic-conventions. Compare the length & complexity of a script like gnuplot.sourceforge.net/demo_5.0/heatmaps.7.gnu to a typical use of xyz directly on the data. – arielf Nov 28 '18 at 9:30
2

Gnuplot should fit your needs. It's a portable command-line driven graphing utility for Linux, OS/2, MS Windows, OSX, VMS, and many other platforms. It's relatively easy to use and you will find many tutorials around the internet. Supports many outputs formats like pdf, png, gif, jpeg, LaTeX, metafont, emf, svg and HTML5. According to the demonstrations available in the project website, it is able to produce 2D and 3D heatmaps.

| improve this answer | | | | |
1

One possibility is to use python macro scripting within LibreOffice:

  • LibreOffice 5 comes with a python 3.3.5 installation within it
  • python has a number of graphing components available which it seems can be installed
  • Python and most of the libraries are Free, gratis & open source and cross platform.
| improve this answer | | | | |
  • 1
    ... but aren't you essentially telling me to implement this myself based on general-purpose libraries? :-) – einpoklum Sep 1 '16 at 17:42
  • 1
    @einpoklum - I am telling you that you can have exactly what you would like if you put some building blocks together. – Steve Barnes Sep 1 '16 at 18:38
  • 2
    If you would like to try an online service there is plot.ly/alpha/workspace does heatmaps from excel or excel like data. – Steve Barnes Sep 1 '16 at 19:02
1

@arielf used a standard example from R but he does not mention direct solution using plotly library. Moreover, R is also powerful for importing datasets (e.g. read.csv which you can apply also to locale csv).

https://plotly.com/r/heatmaps/

Intuitivity of use: R is not the easiest language

Ease of input ingestion: R community is huge

Speed: R is fast

Support for infinte-resolution maps: not sure what this means

Ability to produce output files in various formats: using RStudio you can create pdf and html, export to image is also possible (jpg, png, svg)

Configurability and tweakability: probably the same as other software

RStudio is free for Windows and Linux.

| improve this answer | | | | |
  • Can you expand a little more on plotly w.r.t the criteria I mentioned in my question? – einpoklum Apr 19 at 19:32
  • Well, it saved my day. I have a spreadsheet with many sheets and have to create a heatmap by combining columns from different sheets. Thus, preprocessing the data is unavoidable and I first separate data to a set of csv files and then use R to combine them together. When already in R, creating heatmap using plotly library are just one or two additional lines. – meolic Apr 19 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.