有什么方法可以在matplotlib中使用双变量颜色图吗? [英] Is there any way to use bivariate colormaps in matplotlib?

查看:151
本文介绍了有什么方法可以在matplotlib中使用双变量颜色图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

换句话说,我想制作一个热图(或表面图),其中颜色根据 2 变量而变化. (具体来说,亮度=幅度,色调=相位.)是否有任何本地方法可以做到这一点? 相似情节的一些例子:

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 = phase.) Is there any native way to do this? Some examples of similar plots:

完全是(? )我想做什么.

更多来自天文学的示例,但具有非感知色调

推荐答案

imshow将采用NxMx3(rbg)或NxMx4(grba)数组,因此您可以手动"进行颜色映射.

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

通过将Normalize子类化以将矢量映射到定标器并巧妙地自定义颜色映射 ,您也许能够获得一点吸引力(但是我认为这将结束必须将您的尺寸之一加进仓).

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).

我已经做过这样的事情( pdf链接,请参见第页24),但代码在MATLAB中(并藏在我的档案中的某个位置).

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).

我同意使用双变量颜色映射是有用的(主要用于表示非常密集的矢量场,无论您做什么,都可能使小溪流过). 我认为明显的扩展是让颜色映射采用复杂的参数.这将需要NormalizeColormap的专门子类,如果我认为要实施很多工作,我会来回走下去.我怀疑如果您手动操作它,将只是api争吵的问题.

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.

这篇关于有什么方法可以在matplotlib中使用双变量颜色图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆