- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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') plt.tick_params(rotation=45) plt.show()
- Related Articles
- How to make a 4D plot with Matplotlib using arbitrary data?
- How to create custom markers on a plot in Matplotlib
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How to plot CSV data using Matplotlib and Pandas in Python?
- How to plot a bar graph in Matplotlib from a Pandas series?
- How to Add Markers to a Graph Plot in Matplotlib with Python?
- How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?
- How to plot a kernel density plot of dates in Pandas using Matplotlib?
- How to plot certain rows of a Pandas dataframe using Matplotlib?
- How do you plot a vertical line on a time series plot in Pandas?
- How to plot histograms from dataframes in Pandas using Matplotlib?
- How to plot a Pandas Dataframe with Matplotlib?
- How to plot data against specific dates on the X-axis using Matplotlib?
- How to make markers on lines smaller in Matplotlib?
- How to plot events on time using Matplotlib?