0

I have a function ℝ² → ℝ², for example electrical charge and pressure across a surface. I would like to display this as a heatmap. So I need a mapping from ℝ² to colors (ℝ³) to convert the output to colors.

Matplotlib provides colormaps but as far as I understand they only represent a single dimensional value. Is there a standard way to display 2 channel data as heatmaps in matplotlib? The image can be processed outside/manually, but then it does not integrate well, for example it displays the RGB data where the cursor is hovering, not the data values.

Thanks!

user7834
  • 13
  • 3

1 Answers1

0

This is in general non-trivial, but you might do something like map the first data set (charge) to RGB using your favourite colormap, and then adjust the intensity of the RGB values according to the pressure on the surface.

There are some similar approaches here: How can I add a 2D colorbar, or a color wheel, to matplotlib?

Jody Klymak
  • 4,979
  • 2
  • 15
  • 31
  • It is certainly nontrivial. I would imagine it to be a quite common requirement though so I am surprised there are not solutions already. If that is really the case maybe I will publish something myself. Thank you for the answer. – user7834 Jul 20 '21 at 19:17
  • I don't think it is that common, because it is very hard to do well, and usually depends on the data. I can think of a few published examples, but not many. – Jody Klymak Jul 20 '21 at 20:20