I have a dataframe(first few rows):
I can plot it with matplotlib.pyplot:
fig = plt.figure()
ax1 = fig.add_subplot(111, ylabel='Price')
df1[['Close']].plot(ax=ax1)
To get:
What I would like to do is to add a marker to plot, down triangle, at the index 2018-09-10 04:00:00 which is indicated by the value -1 in the position column of the dataframe.
I tried to do this:
fig = plt.figure()
ax1 = fig.add_subplot(111, ylabel='Price')
df1[['Close']].plot(ax=ax1)
ax1.plot(
df1.loc[df1.positions == -1.0].index,
df1.Close[df1.positions == -1.0],
'v', markersize=5, color='k'
)
I get the plot like this:
So two things. One is that the index gets converted to something that shoots to year 2055, I don't understand why. Plus is there a way to add a marker at the specific position using just the first plot call? I tried to use markevery but with no success.


