I am wondering how I can pass matplotlibs where="post" into a pandas plot.
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.randn(36, 3))
df.plot(drawstyle="steps", linewidth=2)
# this doesn't work
df.plot(drawstyle="steps", where='post')
Does anyone know how to realize this?
Thanks in advance!
You just need to specify drawstyle="steps-post"
:
df = pd.DataFrame(np.random.randn(36, 3))
df.plot(drawstyle="steps", linewidth=2)
df.plot(drawstyle="steps-post", linewidth=2)
Compare the result:
Why not just use a matplotlib plot? Click here for an example.
from matplotlib import pyplot as plt
plt.step(range(len(df.index)),df[0],where='post')
plt.step(range(len(df.index)),df[1],where='post')
plt.step(range(len(df.index)),df[2],where='post')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With