Given the following data:
df1 abc 1/1/2017 -162 1525 -41 1/2/2017 192 1530 86 1/3/2017 33 1520 -124 1/4/2017 173 1502 -108 1/5/2017 194 1495 -31 1/6/2017 -15 1520 -46 1/7/2017 52 1525 181 1/8/2017 -2 1530 -135 1/9/2017 37 1540 65 1/10/2017 197 1530 73 df2 a 1/3/2017 33 1/6/2017 -15 1/7/2017 52 1/8/2017 -2 1/9/2017 37
How can I create on a chart using matplotlib, which displays the column 'b' df1 and, in addition, puts the markers on the same storyline, but using index points from df2 .
The desired chart will look something like this:

I looked at this answer , but could not fully adapt it. The problem is that in this example they use values, but in my case the part that is common between the two datasets is the index
This is the code from the question I tried:
xs = df1['b'] ys = df2['a']
But the chart returns empty:
TypeError: <class 'NoneType'> type object None
I also tried
xs = df1['b'] markers_on = list(df2.index) plt.plot(xs, '-gD', markevery=markers_on) plt.show()
But I get
ValueError: `markevery` is iterable but not a valid form of numpy fancy indexing
source share