網站首頁 編程語言 正文
python 如何取出colormap中的部分色標
平常我們在繪制填色圖時,經常會使用到各種colormap,但是python提供的一些 colormap色標有時候不那么合適,需要我們裁剪一下進行使用。
官網colormap例子鏈接如下:
colormap
本文提供了一種方法,可以提取colormap色標中的一部分,取出我們滿意的色標區域。下面以jet
為例,進行演示
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
相關推薦
- 2022-05-20 快速安裝Docker詳細步驟教程_docker
- 2022-11-17 python??Matplotlib繪圖直線,折線,曲線_python
- 2023-04-02 淺談Android開發Webview的Loading使用效果_Android
- 2022-10-05 Python中matplotlib庫安裝失敗的經驗總結(附pycharm配置anaconda)_py
- 2024-02-26 gitlab合并分支
- 2022-07-06 React創建對話框組件的方法實例_React
- 2022-09-17 使用cache加快編譯速度的命令詳解_相關技巧
- 2022-09-05 SpringBoot 自動配置原理
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支