Is there any way to use bivariate colormaps in matplotlib?

后端 未结 2 1426
鱼传尺愫
鱼传尺愫 2020-12-03 08:23

In other words, I want to make a heatmap (or surface plot) where the color varies as a function of 2 variables. (Specifically, luminance = magnitude and hue = phas

2条回答
  •  时光说笑
    2020-12-03 08:48

    imshow will take an NxMx3 (rbg) or NxMx4 (grba) array so you can do your color mapping 'by hand'.

    You might be able to get a bit of traction by sub-classing Normalize to map your vector to a scaler and laying out a custom color map very cleverly (but I think this will end up having to bin one of your dimensions).

    I have done something like this (pdf link, see figure on page 24), but the code is in MATLAB (and buried someplace in my archives).

    I agree a bi-variate color map would be useful (primarily for representing very dense vector fields where your kinda up the creek no matter what you do). I think the obvious extension is to let color maps take complex arguments. It would require specialized sub-classes of Normalize and Colormap and I am going back and forth on if I think it would be a lot of work to implement. I suspect if you get it working by hand it will just be a matter of api wrangling.

提交回复
热议问题