Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

plot bar chart python with resulting numbers

#If you want to just label the data points above the bar, you could use plt.annotate()
import numpy as np
import matplotlib.pyplot as plt

n = [1,2,3,4,5,]
s = [i**2 for i in n]
line = plt.bar(n,s)
plt.xlabel('Number')
plt.ylabel("Square")

for i in range(len(s)):
    plt.annotate(str(s[i]), xy=(n[i],s[i]), ha='center', va='bottom')

plt.show()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #plot #bar #chart #python #resulting #numbers
ADD COMMENT
Topic
Name
8+5 =