图未显示X轴和Y轴标签和值以及图表标题
我是python的新手,只是遵循教程,但输出与预期 matplotlib
并未在图表上显示任何内容。
这是这里的代码
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
packets = ['1.', '2', '3', '4', '5']
testTime = [2.3,1.7,3.5,2.9,1.2]
plt.bar(packets,testTime)
plt.ylabel('Responsi time (Seconds.milliseconds)')
plt.xlabel('Packets')
plt.title("Response Time")
plt.show()
是输出屏幕截图
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过此
图。ADD_AXES([0,0,1,1])
轴将覆盖整个图,将其删除或添加分数(小于1),您会没事的:输出:
by this
fig.add_axes([0,0,1,1])
the axes will cover the whole plot, remove it or add a fraction (less than 1) , and you will be fine :output:
除了答案, @eshirvana :
如果您不知道要用于
AX .add_axes([[0,0,1,1])
,但是,您确实需要Axesax
(例如子图),您可以执行以下操作:ax = ax =图。ADD_SUBPLOT(111)
。这将创建一个1x1的网格,并将子图放在位置1(对将值传递给add_subplot
的更详细说明意味着可以找到在这里)。add_subplot()
的文档可以找到。以及对In addition to the answer by @eshirvana:
If you don't know what fractions to use for
ax = fig.add_axes([0,0,1,1])
, however, you do need the axesax
(e.g. for subplots), you can do the following:ax = fig.add_subplot(111)
. This creates a grid of 1x1 and places the subplot at position 1 (a more detailed explanation of what the value passed toadd_subplot
means can be found here).The documentation of
add_subplot()
can be found here. And an explanation for the