zuecho
zuecho

Reputation: 118

How to draw a bar range plot with matplotlib?

I am trying to create a bar range plot with a temporal x-axis with matplotlib. As an example see the following :

plot

As far as I see, Matplotlib doesn't directly support this kind of plot. What is the best way to achieve this?

Maybe its possible to adjust a boxplot or a fill_between plot?

Upvotes: 4

Views: 8116

Answers (1)

Sam Mason
Sam Mason

Reputation: 16194

just pass the bottom parameter to bar, e.g:

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(10)
y_bot = np.linspace(30, 50, 10)
y_dif = np.linspace(10, 5, 10)

plt.bar(x, y_dif, bottom=y_bot)

Upvotes: 6

Related Questions