9951 explained code solutions for 126 technologies


python-matplotlibHow to set x labels for bar chart


import matplotlib.pyplot as plt
plt.bar([1,2,3], [10, 11, 12])
plt.xticks([1,2,3], ['UA', 'UK', 'USA'])
plt.show()ctrl + c
import matplotlib.pyplot as plt

loads Matplotlib module to use plotting capabilities

.bar

will plot bar chart

[1,2,3]

x-axis values

[10, 11, 12]

y-axis values

xticks

set specified labels for x-axis

['UA', 'UK', 'USA']

labels to use for x axis