- 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 create custom markers on a plot in Matplotlib
To create a custom marker on a plot or graph, we use a list where we write the markers we want to see in the plot. The markers are nothing but symbols, emoji, character or any character which we want to see on the figure.
In order to create the marker, we will first import the required libraries.
import matplotlib.pyplot as plt import numpy as np
For now, we will create a marker on a sine curve. Let us create the grid with size (12,6),
x = np.arange(1, 2.6, 0.1) y = np.sin(2 * np.pi * x) plt.subplots(figsize=(12,6))
Here we will create the list of custom markers,
custom_markers = ['$'+x+'$' for x in ['£','\$','\%','\clubsuit','\diamondsuit','\spadesuit','\heartsuit','\sigma','😍" />']]
Now let us plot the sine Curve,
for i,marker in enumerate(custom_markers): plt.plot(x, 2*(i+2)*y, marker=marker, markersize=15)
Display the figure,
- Related Articles
- How to plot arbitrary markers on a Pandas data series using Matplotlib?
- How to Add Markers to a Graph Plot in Matplotlib with Python?
- How to make markers on lines smaller in Matplotlib?
- How to use different markers for different points in a Pylab scatter plot(Matplotlib)?
- How to set same color for markers and lines in a Matplotlib plot loop?
- How to use a custom png image marker in a plot (Matplotlib)?
- How to create a Swarm Plot with Matplotlib?
- How to plot data into imshow() with custom colormap in Matplotlib?
- Add a custom border to certain cells in a Matplotlib / Seaborn plot
- How to plot 4D scatter-plot with custom colours and cutom area size in Python Matplotlib?
- How to create minor ticks for a polar plot in matplotlib?
- How to create a Scatter Plot with several colors in Matplotlib?
- How to plot a point on 3D axes in Matplotlib?
- Create a grouped bar plot in Matplotlib
- How to plot additional points on the top of a scatter plot in Matplotlib?