Example code for creating broken barh graph using matplotlib

0 votes
Can I have an example code for creating broken barh graph using matplotlib? Thank you
May 27 in Python by Tanvi
22 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Try this, it should work well.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='tab:blue')
ax.broken_barh([(10, 50), (100, 20), (130, 10)], (20, 9),
               facecolors=('tab:orange', 'tab:green', 'tab:red'))
ax.set_ylim(5, 35)
ax.set_xlim(0, 200)
ax.set_xlabel('seconds since start')
ax.set_yticks([15, 25])
ax.set_yticklabels(['Bill', 'Jim'])
ax.grid(True)
ax.annotate('race interrupted', (61, 25),
            xytext=(0.8, 0.9), textcoords='axes fraction',
            arrowprops=dict(facecolor='black', shrink=0.05),
            fontsize=16,
            horizontalalignment='right', verticalalignment='top')

plt.show()
answered May 27 by Himanshu

Related Questions In Python

+2 votes
2 answers

How can I plot a k-dsitance graph using python?

Hi there, instead of sklearn you could ...READ MORE

answered Apr 10, 2018 in Python by charlie_brown
• 7,710 points
870 views
+1 vote
1 answer
0 votes
1 answer

Iterating over dictionaries using 'for' loops

key is just a variable name. for key ...READ MORE

answered Oct 8, 2018 in Python by SDeb
• 10,780 points
32 views
0 votes
1 answer

How can I Iterate over dictionaries using 'for' loops

key is just a variable name. for key in ...READ MORE

answered Oct 17, 2018 in Python by Priyaj
• 56,140 points
50 views
0 votes
1 answer

An example showing how to plot the coherence of two signals

This should work well: import numpy as np import ...READ MORE

answered May 27 in Python by anonymous

edited May 27 by Kalgi 13 views
0 votes
1 answer

Example of creating horizontal bar chart using matplotlib

Try this: import matplotlib.pyplot as plt import numpy as ...READ MORE

answered May 27 in Python by Vaishnavi
12 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.