Home > Net >  Ploting Stem plot in pandas
Ploting Stem plot in pandas

Time:02-06

I have the following code:

import pandas as pd
from pandas_datareader import data as web
import datetime

df = web.DataReader('tip', 'yahoo', start= '1,1,2017', end = datetime.datetime.today())
df1 = df.resample('W-Mon').mean()
df1["Adj Close"].pct_change().plot()

This produces this plot:

enter image description here

To plot in stem in pandas:

df1["Adj Close"].pct_change().stem()

Is producing this error:

AttributeError: 'Series' object has no attribute 'stem'

CodePudding user response:

You could use matplotlib:

import matplotlib.pyplot as plt
plt.stem(df1["Adj Close"].pct_change().index,
        df1["Adj Close"].pct_change())
plt.show()

Then customise axis/title as you like.

enter image description here

  •  Tags:  
  • Related