import matplotlib.pyplot as plt import numpy as np import scipy as sci # Fixing random state for reproducibility np.random.seed(19680801) # Example data people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim') y_pos = np.arange(len(people)) performance = 3 + 10 * np.random.rand(len(people)) error = np.random.rand(len(people)) fig, ax = plt.subplots() hbars = ax.barh(y_pos, performance, xerr=error, align='center') ax.set_yticks(y_pos) ax.set_yticklabels(people) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Performance') ax.set_title('combien de fois avez-vous regardé votre téléphone pendant la dernière heure ?') # Label with specially formatted floats #ax.bar_label(hbars, fmt='%.2f') ax.set_xlim(right=15) # adjust xlim to fit labels plt.show() # coding = utf8