对于具有自定义级别的 matplotlib 轮廓图,颜色图被忽略
我正在尝试在 matplotlib (Win7,1.1.0)中创建填充轮廓图。我想突出显示某些值,并且级别更接近对数而不是线性。
有许多颜色图适合我,但我选择的 cmap 被忽略了。
我需要创建自定义“标准化”吗?如果是这样,每个轮廓是否根据其边缘值着色,然后用相同的颜色填充到下一个较低的值?为什么这个症状会忽略我的颜色图......这是施工过程中的一些异常被捕获并且我的请求被默默地忽略吗?
我的原始数据有缺失值。我尝试过制作这个纳米,大的和小的......在每种情况下,我都尝试掩盖它们而不是掩盖“外部”值。我还使用默认级别和规范尝试了所有排列。
lev = [0.1,0.2,0.5,1.0,2.0,4.0,8.0,16.0,32.0]
norml = colors.normalize(0,32)
cs = plt.contourf(x,z,data,cmap=cm.gray, levels=lev, norm = norml)
我希望这个片段至少足以开始对话。
谢谢, 伊莱
I am trying to create a filled contour plot in matplotlib (Win7, 1.1.0). I want to highlight certain values, and the levels are closer to log than linear.
There are numerous colormaps that would suit me, but my choice of cmap is ignored.
Do I need to create a custom "normalize"? If so is each contour colored according to its edge value and then filled with the same color to the next lower value? Why is the symptom of this to ignore my color map ... is this some exception during construction that is being caught and my request is being silently ignored?
My original data had missing values. I have played with making thise nan, large and small ... in each case I have tried masking them and not masking the "outside" values. I have also tried all permutations using the default levels and norm.
lev = [0.1,0.2,0.5,1.0,2.0,4.0,8.0,16.0,32.0]
norml = colors.normalize(0,32)
cs = plt.contourf(x,z,data,cmap=cm.gray, levels=lev, norm = norml)
I hope this snippet is sufficient to at least start the conversation.
Thanks,
Eli
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您需要使用级别作为基础而不是默认的线性缩放来将数据重新缩放为颜色。如果这是正确的,那么您需要使用
colors.BoundaryNorm
作为标准因子。考虑以下示例:
这会产生
将其与默认
Normalize
行为进行比较:< img src="https://i.sstatic.net/BOo2k.png" alt="在此处输入图像描述">
希望有所帮助。
If I understood you correctly, you need to rescale your data to colors using your levels as the basis rather than default linear scaling. If that's right, then you need to use
colors.BoundaryNorm
as the norm factor. Consider the following example:This yields
Compare it to default
Normalize
behaviour:Hope that helps.