在matplotlib中合并多个热图 [英] Combine multiple heatmaps in matplotlib

查看:455
本文介绍了在matplotlib中合并多个热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前面临着可视化三维数据的问题。具体来说,我有两个变化的参数,第三个维度是结果输出,在这种情况下,它是一个介于零和一(百分比)之间的值。

I am currently facing the problem of visualizing three dimensional data. Concretely, I have two parameters that are varying and the third dimension is the resulting output which in this case is a value between zero and one (percentage).

我想说明几个不同的数据集。与在matplotlib(pcolor)中使用热图一起使用时效果很好。

I have several distinct datasets that I want to illustrate. It is working well with using heatmaps in matplotlib (pcolor).

但是,我想直接比较不同的数据集。我对为每个数据集生成单独的图并以此方式表示并不满意。我想以某种方式将其绘制成一个图,以便能够直接比较它们。

However, I want to directly compare the distinct datasets with each other. I am not quite happy with producing a seperate plot for each dataset and representing it this way. I somehow want to plot it in one figure to be able to directly compare them.

我尝试了3D图(散点图和曲面图),该图工作得很不错,但是值是重叠的,大多数时候您只能看到一个数据集。 3D绘图确实不能很好地工作。

I have tried 3D plots (scatter and surface) which is working quite decent, but the values are overlapping and most of the time you can only see one dataset. 3D Plots are really not working that well.

所以我的主要问题是,是否有人对如何在一个绘图中表示这一点有所了解。

So my main question is if someone has an idea of how I could represent this in one plot.

致谢!

推荐答案

有一些选项可以一起显示2个数据集:

There are a few options to present 2 datasets together:

选项1 -绘制两个数据集(或比率,视情况而定)之差的热图

Options 1 - draw a heatmap of the difference of 2 datasets (or ratio, whatever is more appropriate in your case)

pcolor(D2-D1)

,然后显示其中几个比较数字。

and then present several of these comparison figures.

选项2 -将1个数据集显示为pcolor,另一个显示为countour:

Option 2 - present 1 dataset as pcolor, and another as countour:

pcolor(D1)
contour(D2)

如果您确实需要一起显示N> 2个数据集,则可以使用轮廓线或轮廓线f:

If you really need to show N>2 datasets together, I would go with contour or contourf:

contourf(D1,cmap='Blues')
contourf(D2,cmap='Reds', alpha=0.66)
contourf(D2,cmap='Reds', alpha=0.33)

contour(D1,cmap='Blues')
contour(D2,cmap='Reds')
contour(D2,cmap='Reds')

不幸的是,类似的alpha技巧不能与pcolor一起使用。

unfortunately, simiar alpha tricks do not work well with pcolor.

这篇关于在matplotlib中合并多个热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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