python - matplotlib not displaying the graph bars -


i'm trying plot show on graph not show reason. have imported matplotlib library, getting values function , when pass values function want plot shown displays blank image. show getting correct values have used print along plotting commands values getting printed not plot here's code. able plot correct using

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 sex')     plt.ylabel('number of people')     plt.show() counts   = getcounts(titanic) get_plot(counts) 

i'm trying 2 bars placed in there 'male' , 'female' , not sure how able to. , code above able put 1 of it. please in advance.

you may want revisit plt.bar documentation says

pyplot.bar(left, height, width=0.8, bottom=none, hold=none, data=none, **kwargs)
[...]
left : sequence of scalars x coordinates of left sides of bars
height : scalar or sequence of scalars height(s) of bars

you may position bars @ indizes 0 , 1 , height given points

plt.bar(range(len(points)),points) plt.xticks(range(len(points)), points.index) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -