对matplotlib改变colorbar位置和方向的方法详解
作者:jingxian 时间:2023-07-13 21:00:04
如下所示:
#! usr/bin/python
#coding=utf-8
import numpy as np
import matplotlib.pyplot as plt
data=np.random.rand(10,10)
fig, ax=plt.subplots()
data[data==-1]=np.nan#去掉缺省值-1
im =ax.imshow(data,interpolation='none',cmap='Reds_r',vmin=0.6,vmax=.9)#不插值
#去掉边框
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)
########################################################################
position=fig.add_axes([0.15, 0.05, 0.7, 0.03])#位置[左,下,右,上]
cb=plt.colorbar(im,cax=position,orientation='horizontal')#方向
来源:https://blog.csdn.net/ginynu/article/details/68944918
标签:matplotlib,colorbar
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
成为一个顶级设计师的第一准则
2008-04-18 10:29:00
![](https://img.aspxhome.com/file/UploadPic/20084/18/2008418103351248s.jpg)
Python实现扫码工具的示例代码
2022-07-06 06:06:36
浅谈一下基于Pytorch的可视化工具
2022-12-28 23:08:07
![](https://img.aspxhome.com/file/2023/2/128452_0s.png)
SQL查询排名函数实例
2024-01-22 13:14:10
![](https://img.aspxhome.com/file/2023/3/91153_0s.jpg)
Flask框架 CSRF 保护实现方法详解
2021-07-05 08:27:05
将HTML表单数据存储为XML格式
2007-08-23 13:04:00
Python之ReportLab绘制条形码和二维码的实例
2023-06-26 09:43:30
![](https://img.aspxhome.com/file/2023/5/135005_0s.jpg)
python matplotlib绘图实现删除重复冗余图例的操作
2023-11-02 22:36:44
Python实现在tkinter中使用matplotlib绘制图形的方法示例
2022-12-16 03:43:37
![](https://img.aspxhome.com/file/2023/3/117413_0s.png)
Python实战之多种音乐格式批量转换
2023-07-12 20:24:42
![](https://img.aspxhome.com/file/2023/4/128544_0s.png)
Python多线程应用于自动化测试操作示例
2021-04-09 19:20:58
![](https://img.aspxhome.com/file/2023/2/99022_0s.png)
Python+pyftpdlib实现局域网文件互传
2022-01-10 04:09:30
![](https://img.aspxhome.com/file/2023/2/112782_0s.png)
php 无法载入mysql扩展
2023-09-07 13:07:40
520必备!这些Python表白代码祝你脱单成功
2023-01-29 15:16:39
![](https://img.aspxhome.com/file/2023/3/101463_0s.jpg)
JavaScript能判定两个function等价吗?
2009-08-13 14:45:00
解决Pytorch修改预训练模型时遇到key不匹配的情况
2022-11-29 15:43:43
Python3网络爬虫开发实战之极验滑动验证码的识别
2022-10-02 22:06:14
![](https://img.aspxhome.com/file/2023/1/85221_0s.jpg)
JS中的async与await怎么使用
2024-05-02 16:19:31
兼容IE,FF的弹出层登陆界面代码
2008-01-04 12:13:00
![](https://img.aspxhome.com/file/UploadPic/20081/4/200814122333734s.jpg)
MySQL执行update语句和原数据相同会再次执行吗
2024-01-20 16:49:31