[英]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.