解决 UserWarning: Matplotlib is currently using agg ... 的一种方法

解决自己编译的 python 运行绘图时报错如下:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. plt.show()
根据自己的实际经验,需要如下几步:

  1. 安装 tcl-develtk-devel 软件包
  2. 重新从 python 源码配置一遍,然后编译安装
    在这里插入图片描述就可以了,我的测试代码:
#!/usr/bin/python
import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
#matplotlib.use('TkAgg')
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

x3=[0,10,10,20,30,40,50,60,70,80,90,100,100,100,100,100,100,100,100,100,100,100,100,100]
y3=[35,36.9,40,45,46,47,48,49,50,51,52,53,54,55,56,67,58,59,60,61,62,63,64,65]
z3=[32.3,38.95,46.59,52.9,54,56.93,58.92,59.93,60.96,61.98,64.7,65.13,66.19,66.19,66.19,67.27,67.27,67.27,67.27,67.27,67.27,68.35,68.35,69.44]

print(len(x3), len(y3), len(z3))
ax.plot(x3,y3,z3,label='hello')
plt.show()

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值