0

I have a bar chart I am tryin to generate for a data science visualization I want to generate fro a project of mine.

I have the bar chart generating correctly. I want to add text to the top of each column with its value that is being displayed so that the person looking at it can see the exact values.

I am having a lot of trouble with getting the text to render.

Here is the code for the graph.

x_axis_ticks = ['tech company', 'non tech company']
X = np.arange(len(x_axis_ticks))
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.bar(X + 0.00, compare_values[0], color = 'g', width = 0.25)
ax.bar(X + 0.25, compare_values[1], color = 'r', width = 0.25)

ax.set_ylabel('# of people')
ax.set_xlabel('Family history of mental illness')
ax.set_title('# of people who have claimed to have mental healht issues based on their family history.')
ax.legend(labels=['Family History (yes)', 'Family Hisotry (No)'])
plt.show()

Here is waht is being generated:

bar chart

  • 1
    Does this answer your question? [How to display the value of the bar on each bar with pyplot.barh()](https://stackoverflow.com/questions/30228069/how-to-display-the-value-of-the-bar-on-each-bar-with-pyplot-barh) – Christian Karcher May 16 '22 at 06:30

0 Answers0