Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c0dc45

Browse files
committed
DOC: modernise barh example
1 parent 829cea2 commit 9c0dc45

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

  • galleries/examples/lines_bars_and_markers

galleries/examples/lines_bars_and_markers/barh.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@
66
This example showcases a simple horizontal bar chart.
77
"""
88
import matplotlib.pyplot as plt
9-
import numpy as np
10-
11-
# Fixing random state for reproducibility
12-
np.random.seed(19680801)
139

1410
fig, ax = plt.subplots()
1511

1612
# Example data
1713
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
18-
performance = 3 + 10 * np.random.rand(len(people))
19-
error = np.random.rand(len(people))
14+
performance = [5, 7, 6, 4, 9]
15+
error = [0.2, 0.4, 0.3, 0.6, 0.2]
2016

2117
ax.barh(people, performance, xerr=error, align='center')
22-
ax.invert_yaxis() # labels read top-to-bottom
18+
ax.yaxis.set_inverted(True) # labels read top-to-bottom
2319
ax.set_xlabel('Performance')
2420
ax.set_title('How fast do you want to go today?')
2521

0 commit comments

Comments
 (0)