網(wǎng)站首頁 編程語言 正文
python 如何取出colormap中的部分色標(biāo)
平常我們在繪制填色圖時,經(jīng)常會使用到各種colormap,但是python提供的一些 colormap色標(biāo)有時候不那么合適,需要我們裁剪一下進(jìn)行使用。
官網(wǎng)colormap例子鏈接如下:
colormap
本文提供了一種方法,可以提取colormap色標(biāo)中的一部分,取出我們滿意的色標(biāo)區(qū)域。下面以jet
為例,進(jìn)行演示
import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import numpy as np from matplotlib.colors import ListedColormap, LinearSegmentedColormap ax = plt.subplot() cmap=plt.get_cmap('jet') newcolors=cmap(np.linspace(0, 1, 256)) newcmap = ListedColormap(newcolors[57:245]) im = ax.imshow(np.arange(100).reshape((10, 10)),cmap=newcmap) # create an axes on the right side of ax. The width of cax will be 5% # of ax and the padding between cax and ax will be fixed at 0.05 inch. divider = make_axes_locatable(ax) cax = divider.append_axes("right", size="5%", pad=0.05) plt.colorbar(im, cax=cax) plt.show()
未改變前:
修改后:
原文鏈接:https://blog.csdn.net/weixin_44237337/article/details/122889771
相關(guān)推薦
- 2023-06-17 go開源Hugo站點(diǎn)渲染之模板詞法解析_Golang
- 2022-05-22 C#中值類型和引用類型的區(qū)別_C#教程
- 2021-12-03 找不到或無法加載主類 CMD || 找不到\*\*\路徑|| 原因大全
- 2022-10-27 Python?Pandas中布爾索引的用法詳解_python
- 2022-05-25 python3?字符串str和bytes相互轉(zhuǎn)換_python
- 2024-03-13 QAobject修改excel字體亂碼問題
- 2024-01-31 linux部署項目, 報數(shù)據(jù)庫連接不上錯誤
- 2022-08-18 nginx之內(nèi)存池的實(shí)現(xiàn)_nginx
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支