0

I am working to create a simple bar chart that displays the number of each of the 9 items listed in a visual format. The goal here is to give a high level summary of the numbers by just glancing at the chart.

With my current code I am able to create a simple bar chart but I would like to have the frequency for each bin printed on top of each bar. How would I proceed to do that.

Here is the code and the current output:

# Graphing the dataset findings

height = [a_counter, b_counter, c_counter, d_counter, e_counter, f_counter, g_counter, h_counter, i_counter]


#print (height)

label = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']

#print (label)
def plot_bar_x():
    # this is for plotting purpose
    index = np.arange(len(label))
    plt.bar(index, height)
    plt.xlabel('Classes', fontsize=25)
    plt.ylabel('Frequency', fontsize=25)
    plt.xticks(index, label, fontsize=10, rotation=20)
    plt.title('Class Distribution for Current Network')
    plt.show()


plot_bar_x()

output image for above code

Veejay
  • 397
  • 3
  • 10
  • 17

0 Answers0