In [2]:
import matplotlib

import matplotlib.pyplot as plt
import numpy as np
from platform import python_version

python_version(), np.__version__,matplotlib.__version__
Out[2]:
('3.6.9', '1.19.0', '3.2.2')

simple bar plot

In [3]:
import matplotlib.pyplot as plt
import numpy as np

# generate sample data for this example
xs = [1,2,3,4,5,6,7,8,9,10,11,12]
ys = np.random.normal(loc=3.0,size=12)
labels = ['jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec']

plt.bar(xs,ys)

# HERE tell pyplot which labels correspond to which x values
plt.xticks(xs,labels)

plt.show()

horizontal bar plot

In [5]:
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

xs = [1,2,3,4,5,6,7,8,9,10,11,12]
ys = np.random.normal(loc=3.0,size=12)
labels = ['jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec']

plt.clf()
plt.barh(xs,ys)

# tell pyplot which labels correspond to which x values
plt.yticks(xs,labels)

plt.show()