python matplotlib 绘图 和 dpi对应关系详解
作者:未名亚柳 时间:2023-12-11 18:13:43
我就废话不多说啦!
dpi=1 600×400
dpi=21200×800
dpi=31800×1200
........
dpi=21(21×600)×(21×400) ---> 12600×8400
示例代码:
...............
...............
plt_temp=y_axis
plt_temp.resize(len(y_axis) , 1)
plt_arr=np.concatenate((plt_arr,plt_temp ), axis=1)
#print(self.plt_arr)
if plt_x%1000==0:
print(plt_x)
if plt_x%1000==0:
cm='hot'
norm = matplotlib.colors.Normalize(vmin=min, vmax=max)
map=plt.imshow(plt_arr,interpolation='nearest',cmap=cm,norm=norm, origin='upper')
plt.xticks([])
plt.yticks([])
plt.axis('off')
#plt.colorbar(mappable=map,ax=None,shrink=0.5, pad=0)
plt.savefig("filename.png", dpi=1320) # 加参数 ,bbox_inches='tight' ,pad_inches=0 可以得到窄边框图片
#plt.show()print(plt_x)
plt_x+=1
temp_str=str(num_now)
return donser_now_lable
............
............
上代码读入一个二进制bin数据文件1.08GB的一部分,数据格式为无包头、小端模式、16位编码的频谱数据dpi=1320,生成名称为filename.png的图片
补充知识:Python绘图问题:Matplotlib中指定图片大小
我们在用Matplotlib画图的时候可能会遇到当在一张面板上显示太多的图片时,plt.show出来就会显示的很小
像下图的样子
这时候用改变子图片间距的方法也解决不了问题:
plt.subplots_adjust(wspace=0.1, hspace=0.2)
于是我们用
plt. figure(figsize=(5,8))
# 可以按5比8的大致 比例增加来增大图片的像素
# 例如 plt. figure(figsize=(10,16))
里面的参数第一个5应该是5列,8是8行,如果不行就是试着换成别的参数 但是需要按照大概的比例
按比例增加参数大小以后:
这样就好多了!
来源:https://www.cnblogs.com/dzzy/p/9229284.html
标签:python,matplotlib,dpi
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js读取图片的宽和高
2007-08-04 10:14:00
查看当前mysql使用频繁的sql语句(详解)
2024-01-18 19:58:47
Python利用AutoGrad实现自动计算函数斜率和梯度
2023-09-27 22:47:59
![](https://img.aspxhome.com/file/2023/2/118512_0s.png)
Python中字符串的基本使用详解
2022-08-13 07:05:42
![](https://img.aspxhome.com/file/2023/0/100970_0s.png)
vuex中数据持久化插件vuex-persistedstate使用详解
2024-04-26 17:41:54
![](https://img.aspxhome.com/file/2023/2/133122_0s.png)
SQL 查询性能优化 解决书签查找
2012-10-07 10:23:56
用SELECT... INTO OUTFILE语句导出MySQL数据的教程
2024-01-13 19:50:52
网页设计之文字的辨识度与可读性
2007-10-26 16:19:00
![](https://img.aspxhome.com/file/UploadPic/200710/26/20071026162228999s.gif)
Pycharm添加虚拟解释器报错问题解决方案
2022-05-28 04:07:53
![](https://img.aspxhome.com/file/2023/0/107010_0s.png)
Python2和Python3中@abstractmethod使用方法
2021-12-29 08:55:36
Python中使用PIPE操作Linux管道
2022-02-10 18:25:25
![](https://img.aspxhome.com/file/2023/4/90594_0s.png)
详解Django模版中加载静态文件配置方法
2023-11-16 19:55:13
vue 自定义右键样式的实例代码
2023-07-02 16:33:34
![](https://img.aspxhome.com/file/2023/7/139707_0s.png)
Python中functools模块函数解析
2021-03-11 10:15:40
Python中使用scapy模拟数据包实现arp攻击、dns放大攻击例子
2021-12-04 12:15:05
python切片(获取一个子列表(数组))详解
2022-09-18 01:18:49
详细讲解MySQL数据库对文件操作的封装
2008-12-17 16:08:00
XML的语法、结构以及相关的一些技术
2007-10-23 07:27:00
删除pandas中产生Unnamed:0列的操作
2021-07-27 03:12:03
asp.net实现存储和读取数据库图片
2024-01-19 06:56:32
![](https://img.aspxhome.com/file/2023/8/83208_0s.png)