我使用了matplotlib,但是错误消息``<图形大小720x576带有0个轴>''与图形一起出现 [英] I used matplotlib, but the error message '<Figure size 720x576 with 0 Axes>' appeared with graph

查看:620
本文介绍了我使用了matplotlib,但是错误消息``<图形大小720x576带有0个轴>''与图形一起出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import matplotlib.pyplot as plt
from matplotlib import font_manager, rc

f_name = font_manager.FontProperties(fname='C:/Windows/Fonts/HANBatangExt.ttf').get_name()
rc('font', family=f_name)

뛰기운동

plt.plot(run_before, run_after, 'ro-')

걷기운동

plt.plot(walk_before, walk_after, 'bo-')
plt.figure(figsize=((10,8)))
plt.show()

推荐答案

这不是错误,但您看到的输出是由于您使用过的事实

It is not an error but the output you see is due to the fact that you have used

plt.figure(figsize=((10,8)))

plt.plot 之后.因此,您首先在屏幕上获得一个图形,然后plt.figure 创建一个图形对象.要摆脱它,您应该在绘图之前先设置图形大小,如下所示:

after plt.plot. Therefore, you first get a figure on you screen and a figure object is created by plt.figure. To get rid of it, you should first set the figure size before plotting, something like this:

plt.figure(figsize=((10,8)))
plt.plot(run_before, run_after, 'ro-')
plt.plot(walk_before, walk_after, 'bo-')
plt.show()

还有其他方法可以在绘制后设置图形大小,但是由于您的代码足够精细,因此可以进行上述修改.

There are other ways to set the figure size after plotting but since your code is fine enough, you are good to go with the above modification.

这篇关于我使用了matplotlib,但是错误消息``<图形大小720x576带有0个轴>''与图形一起出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆