How to plot arbitrary markers on a Pandas data series using Matplotlib?

To plot arbitrary markers on a Pandas data series, we can use pyplot.plot() with markers.


  • Set the figure size and adjust the padding between and around the subplots.
  • Make a Pandas data series with axis labels (including timeseries).
  • Plot the series index using plot() method with linestyle="dotted".
  • Use tick_params() method to rotate overlapping labels.
  • To display the figure, use show() method.


import pandas as pd
from matplotlib import pyplot as plt
import numpy as np

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

ts = pd.Series(np.random.randn(10),
index=pd.date_range('2021-04-10', periods=10))

plt.plot(ts.index, ts, '*', ls='dotted', color='red')