[英]matplotlib not displaying the graph bars
我正在尝试使绘图显示在图形上,但是由于某种原因它什么也没显示。 我已经正确导入了matplotlib库,正在正确地从函数中获取值,并且当我将这些值传递给要在其中显示绘图的函数时,它将显示空白图像。 为了显示我得到的正确的值,我已经使用print和plotting命令打印了值,但不是打印图。这是代码。 我能够使用正确的情节
def GetCounts(data):
return (data['Sex'].value_counts())
def Get_Plot(Points):
_x1 = Points[0]
_x2 = Points[1]
_y = (_x1 + _x2) - 200
print('male' + ' ' + str(_x1) + '\n','female' + ' '+ str(_x2), _y)
plt.bar(height = _x1, tick_label = 'Male', left = _x1)
plt.xlabel('Counts of people according to Sex')
plt.ylabel('Number of people')
plt.show()
Counts = GetCounts(titanic)
Get_Plot(Counts)
我正在尝试在“男性”和“女性”中放置2个酒吧,但我不确定我将如何做到。 使用上面的代码,我只能放入其中之一。 请提前帮助谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.