Can I have an example code for creating broken barh graph using matplotlib? Thank you
May 27, 2019 in Python 1,985 views

## 1 answer to this question.

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, 2019 by Himanshu

## Python code for printing the string without vowels using list comprehension

Hey @Anvit, you can use something like ...READ MORE

+1 vote

## How to save graph using matplotlib library?

Hi@akhtar, You can find one function called savefig ...READ MORE

## Write code to create a list of word lengths for the words in original_str using the accumulation pattern and assign the answer to a variable num_words_list.

Hi,  num_words_list = len(original_str.split()) original_str.split() - split words in ...READ MORE

## How to use categorical variables in Matplotlib?

Many times you want to create a ...READ MORE

## An example showing how to plot the coherence of two signals

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