How to Adjust Marker Size in Matplotlib?
In this article, we are going to see how to adjust marker size in Matplotlib in Python.
We can adjust marker size in plots of matplotlib either by specifying the size of the marker in either plot method or scatter method while plotting the graph.
Method 1: Using Plot
plot() method used to plot the graph between 2 data points. It takes 4 parameters those are 2 data points, marker, and marker-size.
Syntax: matplotlib.pyplot.plot(data1, data2, marker=’.’, markersize=constant)
- data1,data2- Variables that hold data.
- marker=’.’ – Indicates dot symbol to mark the datapoints.
- markersize- Represents size of marker
Example 1: Plot a graph using the plot method with standard marker size. (We do not need to mention the marker size in plot method)
Here we just plotted the graph using plot method with standard marker size.
Example 2: To adjust the size of marker in a plot use markersize parameter to plot method to adjust the marker size.
Here in this example, we adjusted the marker size to size 20 such that the maker size is increased from its standard size.
Method 2: Using scatter()
scatter is a method present in matplotlib library which is used to set individual point sizes. It takes 3 parameters 2 data points and a list of marker point sizes.
There is flexibility in scatter that is we can specify the size for each point so that it can be easily distinguished.