Is there a way to disable the interpolation in the pandas area plot? I would like to get a "step-style" area plot. E.g. in the normal line plot it is possible to specify:
import pandas as pd
df = pd.DataFrame({'x':range(10)})
df.plot(drawstyle = 'steps') # this works
#df.plot(kind = 'area', drawstyle = 'steps') # this does not work
I am using python 2.7 and pandas 0.14.1.
Many thanks in advance.
By default uses the index. Column to plot. By default uses all columns. Area plots are stacked by default.
You can interpolate missing values ( NaN ) in pandas. DataFrame and Series with interpolate() . This article describes the following contents. Use dropna() and fillna() to remove missing values NaN or to fill them with a specific value.
Recently an update of .fill_between()
was shipped with matplotlib version 1.5.0 that allows to fill the area between two step functions. This even works with Pandas time series.
Since the argument step='pre'
exists, it can be used like this:
# For error bands around a series df
ax.fill_between(df.index, df - offset, df + offset, step='pre', **kwargs)
# For filling the whole area below a function
ax.fill_between(df.index, df, 0, step='pre', **kwargs)
Additional key word arguments that make sense to me are for example alpha=0.3
and lw=0
.
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