python rgba_python-从matplotlib中的RGBA函数创建颜色条
要创建颜色图,您必须指定红色/绿色/蓝色分量在线性比例上的变化方式.看来您已经有了一个函数f,可以为您设置r / g / b组件.最困难的部分是第四个通道,即alpha通道.给定您的f指定的RGB颜色图,我将通过设置Alpha通道进行设置.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
# some data
a = np.sort(np.random.randn(10, 10))
# use the default 'jet' colour map for showing the difference later
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.imshow(a, cmap=cm.get_cmap('jet'))
fig.savefig('map1.png')
# let's use jet and modify the alpha channel
# you would use your own colour map specified by f
my_cmap = cm.get_cmap('jet')
# this is a hack to get at the _lut array, which stores RGBA vals
my_cmap._init()
# use some made-up alphas, you would use the ones specified by f
alphas = np.abs(np.linspace(-1.0, 1.0, my_cmap.N))
# overwrite the alpha channel of the jet colour map
my_cmap._lut[:-3,-1] = alphas
# plot data with our modified colour map
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.imshow(a, cmap=my_cmap)
fig.savefig('map2.png')
这是map1.png:
这是map2.png:
希望这可以帮助.
python rgba_python-从matplotlib中的RGBA函数创建颜色条相关推荐
- python使用matplotlib中的errorbar函数可视化误差条、并自定义数据点标记、数据点大小、数据点颜色、数据点边缘颜色、误差棒颜色、误差棒线条宽度、误差棒边界线长度、误差棒边界线厚度等
python使用matplotlib中的errorbar函数可视化误差条.并自定义数据点标记.数据点大小.数据点颜色.数据点边缘颜色.误差棒颜色.误差棒线条宽度.误差棒边界线长度.误差棒边界线厚度等 ...
- python中subplot是什么意思_python matplotlib中的subplot函数使用详解
python里面的matplotlib.pylot是大家比较常用的,功能也还不错的一个包.基本框架比较简单,但是做一个功能完善且比较好看整洁的图,免不了要网上查找一些函数.于是,为了节省时间,可以一劳 ...
- python中mat函数_python matplotlib中的subplot函数使用详解
python里面的matplotlib.pylot是大家比较常用的,功能也还不错的一个包.基本框架比较简单,但是做一个功能完善且比较好看整洁的图,免不了要网上查找一些函数.于是,为了节省时间,可以一劳 ...
- pythonsubplot_python matplotlib中的subplot函数使用详解
python里面的matplotlib.pylot是大家比较常用的,功能也还不错的一个包.基本框架比较简单,但是做一个功能完善且比较好看整洁的图,免不了要网上查找一些函数.于是,为了节省时间,可以一劳 ...
- python使用statsmodels包中的tsaplots函数和lags参数可视化时间序列数据指定滞后位置个数(级别)以前的所有自相关性(plot the autocorrelation)
python使用statsmodels包中的tsaplots函数和lags参数可视化时间序列数据指定滞后位置个数(级别)以前的所有自相关性(plot the autocorrelation Funct ...
- python使用statsmodels包中的tsaplots函数可视化时间序列数据所有滞后位置个数(级别)的自相关性(plot the autocorrelation function)
python使用statsmodels包中的tsaplots函数可视化时间序列数据所有滞后位置个数(级别)的自相关性(plot the autocorrelation function) 目录
- python使用statsmodels包中的adfuller函数执行增强迪基-福勒检验(ADF检验、augmented Dickey-Fuller test)、判断时间序列数据是否平稳
python使用statsmodels包中的adfuller函数执行增强迪基-福勒检验(ADF检验.augmented Dickey-Fuller test).判断时间序列数据是否平稳(station ...
- Py之matplotlib:在matplotlib库中利用legend函数创建自定义图例(代码实现)
Py之matplotlib:在matplotlib库中利用legend函数创建自定义图例(代码实现) 目录 matplotlib库中利用legend函数创建自定义图例 原始图像 在原始图像上创建自定义 ...
- Python:numpy库中的一些函数简介、使用方法之详细攻略
Python:numpy库中的一些函数简介.使用方法之详细攻略 目录 numpy库中的一些函数简介.使用方法 1.np.concatenate() 1.1.函数案例 1.2.函数用法 numpy库中的 ...
最新文章
- Ubuntu 12.04安装firefox 26中的flash plugin方法
- 剑灵选区界面一直正在连接服务器,如何选择服务器 选择困难症的指南
- java filter 返回错误消息_java filter 导致错误310
- Vue 进入/离开动画
- mysql错误:……is marked as crashed and should be repai
- java 英文分词器使用代码_java文本英文分词
- 音视频之使用sonic.cpp实现音频倍速播放功能
- Windows 7下实现×××连接自动创建
- 初识EntityFramework6【转】
- MTK:架构和消息机制(必看)
- python ndimage_Python ndimage.zoom方法代码示例
- mongodb和mysql创建表_mongodb入门命令-创建表数据(二)
- 机器学习-百度笔试题
- java中hashmap按键排序_HashMap按键值排序方法
- .dms文档打开方式
- python爬取京东商品信息代码_爬取京东商品信息
- cmap参数 plt_[转]matplotlib - plt.rcParams、matshow/cmap/坐标轴设置
- 基于javaweb+mysql的个人日记管理系统
- (个人解题思路系列)猜拳游戏
- [SWPUCTF 2021 新生赛]第一波放题(nssctf刷题)
热门文章
- iOS 应用架构谈 动态部署方案
- Channels ——django实时推送系统
- 用 python 爬取 某珠宝网站
- Semi-Supervised Training for Improving Data Efficiency in End-to-End Speech Synthesis
- python自动登录百度_python实现自动登录百度账号功能代码
- U美出品||红妆 中式新娘造型欣赏
- BZOJ5059 前鬼后鬼的守护 【堆扩展】*
- 跑步计算--Java
- 详解Unity 5 全局光照系统Enlighten问题(下)
- ENode框架Conference案例分析系列之 - 复杂情况的读库更新设计