StatsPlots.jl icon indicating copy to clipboard operation
StatsPlots.jl copied to clipboard

Heatmap for "long" DataFrames

Open metanoid opened this issue 5 years ago • 3 comments

The available heatmap plot from Plots.jl is built with a particular "shape" of data in mind: the user will define:

  • x - the set of m unique x axis labels
  • y - the set of n unique y axis labels
  • z - an m-by-n shape of data values (usually a Matrix)

But this isn't the shape of the data in the most common scenarios in which I want a heatmap. The shape I usually find myself in is having a DataFrame with

  • an X column with n copies of m x-axis labels
  • a Y column with m copies of n y-axis labels
  • a Z column of m-by-n data values, one for each distinct X and Y pair

In other words, the DataFrame is "long" rather than "wide".

What I think would be nice is some "recipe" in which the user can provide:

  • x - a column to use for x-axis labels
  • y - a column to use for y axis labels
  • z - a column to use for colouring

Right now, my workaround is to use unstack on the DataFrame before plotting, but this is a bit ungainly.

metanoid avatar Dec 10 '19 13:12 metanoid

That makes sense, should be pretty easy to implement

mkborregaard avatar Dec 10 '19 13:12 mkborregaard

That could/should be done for contour, surface and wireframe as well.

daschw avatar Dec 10 '19 14:12 daschw

Any update on this issue?

poglesbyg avatar Jan 13 '21 16:01 poglesbyg