Python Matplotlib等高线图中的非线性缩放

用户129412

我在可视化等高线图中的某个数据集时遇到了一些麻烦。问题是我有很多数据点(X,Y,Z),它们的Z值范围从2到0,其中许多有趣的功能位于0到0.3的范围内。使用普通缩放比例,很难看到它们,如下图所示:

http://i.stack.imgur.com/7O8hH.png

Now, I have thought about what else to do. Of course there is logarithmic scaling, but then I first need to think about some sort of mapping, and I am not 100% sure how one would do that. Inspired by this question one could think of a mapping of the type scaling(x) = Log(x/min)/Log(max/min) which worked reasonably well in that question.

Also interesting was the followup discussed here.

where they used some sort of ArcSinh scaling function. That seemed to enlarge the small features quite well, proportionally to the whole.

So my question is two fold in a way I suppose.

  1. How would one scale the data in my contour plot in such a way that the small amplitude features do not get blown away by the outliers?

  2. Would you do it using either of the methods mentioned above, or using something completely different?

I am rather new to python and I am constantly amazed by all the things that are already out there, so I am sure there might be a built in way that is better than anything I mentioned above.

For completeness I uploaded the datafile here (the upload site is robustfiles.com, which a quick google search told me is a trustworthy website to share things like these)

I plotted the above with

data = np.load("D:\SavedData\ThreeQubitRess44SpecHighResNormalFreqs.npy")

fig, (ax1) = plt.subplots(1,figsize=(16,16))    
cs = ax1.contourf(X, Y, data, 210, alpha=1,cmap='jet')
fig.colorbar(cs, ax=ax1, shrink=0.9)
ax1.set_title("Freq vs B")
ax1.set_ylabel('Frequency (GHz)'); ax1.set_xlabel('B (arb.)')
Oliver W.

Excellent question.

Don't scale the data. You'll be looking for compromises in ranges with many scaling functions.

相反,请使用自定义的colormap这样,您就不必重新映射实际数据,并且可以轻松自定义要突出显示的区域的可视化。可以在scipy食谱中找到另一个示例,互联网上还有很多其他示例

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

给定范围内的matplotlib等高线图

来自分类Dev

将水平值存储在等高线图中

来自分类Dev

等高线图x标签

来自分类Dev

在matplotlib等高线图中手动设置标签错误

来自分类Dev

使用Matplotlib滑块更新等高线图级别

来自分类Dev

将值减去等高线图坐标轴python

来自分类Dev

Matlab:用等高线填充等高线图

来自分类Dev

python中的一个3D图形中的多个2D等高线图

来自分类Dev

使用1D X,Y和Z变量在python中进行2D等高线图

来自分类Dev

多元高斯的等高线图

来自分类Dev

等高线图二元对数正态密度函数python

来自分类Dev

从数据框创建等高线图

来自分类Dev

填充matplotlib等高线图

来自分类Dev

填充matplotlib等高线图

来自分类Dev

在给定范围内的matplotlib等高线图

来自分类Dev

从matplotlib等高线图中提取特定路径

来自分类Dev

八度等高线图

来自分类Dev

等高线图x标记

来自分类Dev

等高线图例-Matplotlib

来自分类Dev

同一图中有多个等高线图

来自分类Dev

Matlab:用等高线填充等高线图

来自分类Dev

Python:用于6系列分数数据(z)的具有固定x和y的2d等高线图

来自分类Dev

Matplotlib等高线图上颜色栏的Python最小和最大范围

来自分类Dev

使用函数绘制等高线图

来自分类Dev

坏等高线图

来自分类Dev

在 matplotlib 等高线图中设置轴比例

来自分类Dev

条件等高线图

来自分类Dev

平滑边缘等高线图

来自分类Dev

Python 中 matplotlib 等高线图的 ValueError