matlab 画框imoverlay,在python中的Imoverlay(Imoverlay in python)

在python中的Imoverlay(Imoverlay in python)

我正在尝试使用matplotlib imshow()将矩阵覆盖在另一个矩阵上。 我希望叠加矩阵为红色,“背景矩阵”为骨骼,色彩映射明智。 因此,简单地添加图像不起作用,因为您只能有一个色彩映射。 除了使用imshow()添加矩阵之外,我还没有找到另一种“叠加”的方法。

我试图或多或少地替换这个matlab 模块 。

请让我知道我有什么替代方案!

I am trying to overlay a matrix over another matrix using matplotlib imshow(). I want the overlay matrix to be red, and the "background matrix" to be bone, colormap wise. So, simply adding the images does not work, as you can only have one colormap. I have yet to find a different way to "overlay" besides just adding the matrices using imshow().

I am trying to, more or less, replace this matlab module.

Please let me know what alternatives I have!

原文:https://stackoverflow.com/questions/8935442

2020-02-13 23:17

满意答案

只需使用蒙面数组 。

例如

import numpy as np

import matplotlib.pyplot as plt

import matplotlib as mpl

x = np.arange(100).reshape(10,10)

y = np.zeros((10,10))

# Make a region in y that we're interested in...

y[4:6, 1:8] = 1

y = np.ma.masked_where(y == 0, y)

plt.imshow(x, cmap=mpl.cm.bone)

plt.imshow(y, cmap=mpl.cm.jet_r, interpolation='nearest')

plt.show()

TXXo5.png

E.g.

import numpy as np

import matplotlib.pyplot as plt

import matplotlib as mpl

x = np.arange(100).reshape(10,10)

y = np.zeros((10,10))

# Make a region in y that we're interested in...

y[4:6, 1:8] = 1

y = np.ma.masked_where(y == 0, y)

plt.imshow(x, cmap=mpl.cm.bone)

plt.imshow(y, cmap=mpl.cm.jet_r, interpolation='nearest')

plt.show()

TXXo5.png

2016-08-19

相关问答

你安装python后会自带一个python编辑器, 在其中一个窗口你能看到以“>>>”开头的行 >>> 就是shell提示符 你可以在>>>后面输入python代码,比如 >>> print "Hello"

print函数是python语言中的一个输出函数,可以输出以下几种内容 1. 字符串和数值类型 可以直接输出 >>> print( 1) 1 >>> print( "Hello World") Hello World 2.变量 无论什么类型,数值,布尔,列表,字典...都可以直接输出 >>> x = 12 >>> print(x) 12 >>> s = 'Hello' >>> print(s) Hello >>> L = [ 1, 2, 'a'] >>> print(L) [ 1, 2, 'a']...

#!/usr/bin/env python # Filename: appui.py """ .. moduleauthor:: .... .. test module of Tkinter """ from Tkinter import * import tkMessageBox root = Tk() root.geometry('850x40+80+80') #设置窗体高宽与窗体相对屏幕左上角位置 class...

eclipse或者aptana里的pydev、pyCharm、Stani's Python Editor

不推荐 《简明python》 讲的太粗糙 一本 python 编程经典 另外一本 就是dive into python 都非常好,如果没什么基础,最好是看编程金典,一个问题一个问题搞懂,绝对没有问题。 不要急着想用python开发如delphi那样的速成GUI, 有基础了,就看看django,相信python不难

没有绝对好的和绝对坏的,而是使用的时候,充分利用他们的优点即可 Go对比Python的优点如下: 一、部署简单。 Go 编译生成的是一个静态可执行文件,除了 glibc 外没有其他外部依赖。这让部署变得异常方便:目标机器上只需要一个基础的系统和必要的管理、监控工具,完全不需要操心应用所需的各种包、库的依赖关系,大大减轻了维护的负担。这和 Python 有着巨大的区别。由于历史的原因, Python 的部署工具生态相当混乱,比如 setuptools, distutils, pip, buildou...

An event can be thought of as a moment in time when something important happens. The problem is, if we want to know when the event happens, we have to watch for it, and that can be expensive. Imagine a phone that, instead off ringing, flashed a light ...

这。。。本身得出的pwd是有问题的,你可以试着将pwd打印出来看下。如果你要进入目录,可以试着用os.chdir()

只需使用蒙面数组 。 例如 import numpy as np

import matplotlib.pyplot as plt

import matplotlib as mpl

x = np.arange(100).reshape(10,10)

y = np.zeros((10,10))

# Make a region in y that we're interested in...

y[4:6, 1:8] = 1

y = np.ma.masked_where(y == 0, y)

pl...

您可以在viewkeys()中使用viewkeys() , viewitems()和viewvalues() 。 >>> dict.viewkeys?

Type: method_descriptor

String Form:

Namespace: Python builtin

Docstring: D.viewkeys() -> a set-like object providing a view on D'...

相关文章

Python 编程语言具有很高的灵活性,它支持多种编程方法,包括过程化的、面向对象的和函数式的。但最重

...

python2和python3的区别,1.性能 Py3.0运行 pystone benchmark的速

...

Python的文件类型 Python有三种文件类型,分别是源代码文件、字节码文件和优化代码文件

源代

...

python的官网:http://www.python.org/ 有两个版本,就像struts1和st

...

好久没有写了,还不是近期刚过的期末考试和期中考试 最近因为一个微信公众平台大赛在学phthon 找了本

...

在python中, 去除了i > 0周围的括号,去除了每个语句句尾的分号,还去除了表示块的花括号。多出

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值