Example of creating horizontal bar chart using matplotlib

0 votes
Can you give an example code creating of horizontal bar chart using matplotlib? Thank you
May 27, 2019 in Python by Naman
1,856 views

1 answer to this question.

0 votes

Try this:

import matplotlib.pyplot as plt
import numpy as np

# Fixing random state for reproducibility
np.random.seed(19680801)

plt.rcdefaults()
fig, ax = plt.subplots()

# Example data
people = ('Tom', '****', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

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('How fast do you want to go today?')

plt.show()
answered May 27, 2019 by Vaishnavi

Related Questions In Python

0 votes
1 answer

Example code for creating broken barh graph using matplotlib

Try this, it should work well. import matplotlib.pyplot ...READ MORE

answered May 27, 2019 in Python by Himanshu
2,228 views
+2 votes
1 answer

How can I record the X,Y limits of a displayed X,Y plot using the matplotlib show() module?

A couple hours after posting this question ...READ MORE

answered Dec 27, 2018 in Python by anonymous
1,143 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 58,020 points
1,576 views
0 votes
1 answer

Is there a way of using .lower more effectively in tkinter?

Here is a simple function and some ...READ MORE

answered Sep 25, 2018 in Python by Priyaj
• 58,020 points
2,346 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,071 views
0 votes
1 answer
0 votes
1 answer

Example showing a way to create a grouped bar chart with Matplotlib?

Have a look at this: import matplotlib import matplotlib.pyplot ...READ MORE

answered May 27, 2019 in Python by Bobin
3,244 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP