我想知道如何将matplotlibs where="post"传递给熊猫情节。
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')
有谁知道如何实现这个目标?
提前致谢!
答案 0 :(得分:23)
您只需指定drawstyle="steps-post"
:
df = pd.DataFrame(np.random.randn(36, 3))
df.plot(drawstyle="steps", linewidth=2)
df.plot(drawstyle="steps-post", linewidth=2)
比较结果:
答案 1 :(得分:0)
为什么不使用matplotlib图? 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')