Matplotlib Marker
In the plotting process, if we want to define some custom markers for the coordinates, we can use the `marker` parameter of the **`plot()`** method.
The following example defines a solid circle marker:
## Example
```python
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([1,3,4,5,8,9,6,1,3,4,5,2,4])
plt.plot(ypoints, marker ='o')
plt.show()
The result is shown below:
!(#)
The symbols that can be defined for `marker` are as follows:
| Marker | Symbol | Description |
| --- | --- | --- |
| "." |  | Point |
| "," |  | Pixel |
| "o" |  | Circle |
| "v" |  | Triangle Down |
| "^" |  | Triangle Up |
| "" |  | Triangle Right |
| "1" |  | Tri Down |
| "2" |  | Tri Up |
| "3" |  | Tri Left |
| "4" |  | Tri Right |
| "8" |  | Octagon |
| "s" |  | Square |
| "p" |  | Pentagon |
| "P" |  | Plus (filled) |
| "*" |  | Star |
| "h" |  | Hexagon 1 |
| "H" |  | Hexagon 2 |
| "+" |  | Plus |
| "x" |  | X |
| "X" |  | X (filled) |
| "D" |  | Diamond |
| "d" |  | Thin Diamond |
| "|" |  | Vline |
| "_" |  | Hline |
| 0 (TICKLEFT) |  | Tick Left |
| 1 (TICKRIGHT) |  | Tick Right |
| 2 (TICKUP) |  | Tick Up |
| 3 (TICKDOWN) |  | Tick Down |
| 4 (CARETLEFT) |  | Caret Left |
| 5 (CARETRIGHT) |  | Caret Right |
| 6 (CARETUP) |  | Caret Up |
| 7 (CARETDOWN) |  | Caret Down |
| 8 (CARETLEFTBASE) |  | Caret Left (centered at base) |
| 9 (CARETRIGHTBASE) |  | Caret Right (centered at base) |
| 10 (CARETUPBASE) |  | Caret Up (centered at base) |
| 11 (CARETDOWNBASE) |  | Caret Down (centered at base) |
| "None", " " or "" | | No marker |
| '$...$' |  | Render the specified text. For example, "$f$" uses the letter 'f' as the marker. |
The following example defines the * marker:
## Example
```python
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([1,3,4,5,8,9,6,1,3,4,5,2,4])
plt.plot(ypoints, marker ='*')
plt.show()
The result is shown below:
!(#)
The following example defines the down caret marker:
## Example
```python
import matplotlib.pyplot as plt
import matplotlib.markers
plt.plot([1,2,3], marker=matplotlib.markers.CARETDOWNBASE)
plt.show()
The result is shown below:
!(#)
### fmt Parameter
The `fmt` parameter defines the basic format, such as marker, line style, and color.
`fmt = ''`
For example, `o:r`, where `o` represents a solid circle marker, `:` represents a dashed line, and `r` represents the color red.
## Example
```python
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([6,2,13,10])
plt.plot(ypoints,'o:r')
plt.show()
The result is shown below:
!(#)
Line Styles:
| Line Style Marker | Description |
| --- | --- |
| '-' | Solid line |
| ':' | Dotted line |
| '--' | Dashed line |
| '-.' | Dash-dot line |
Color Types:
| Color Marker | Description |
| --- | --- |
| 'r' | Red |
| 'g' | Green |
| 'b' | Blue |
| 'c' | Cyan |
| 'm' | Magenta |
| 'y' | Yellow |
| 'k' | Black |
| 'w' | White |
### Marker Size and Color
We can customize the size and color of the markers using the following parameters:
* `markersize`, abbreviated as **`ms`**: Defines the size of the marker.
* `markerfacecolor`, abbreviated as **`mfc`**: Defines the color inside the marker.
* `markeredgecolor`, abbreviated as **`mec`**: Defines the color of the marker's edge.
Setting the marker size:
## Example
```python
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([6,2,13,10])
plt.plot(ypoints, marker ='o', ms =20)
plt.show()
The result is shown below:
!(#)
Setting the marker edge color:
## Example
```python
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([6,2,13,10])
plt.plot(ypoints, marker ='o', ms =20, mec ='r')
plt.show()
The result is shown below:
!(#)
Setting the marker face color:
## Example
```python
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([6,2,13,10])
plt.plot(ypoints, marker ='o', ms =20, mfc ='r')
plt.show()
The result is shown below:
!(#)
Customizing both the marker face and edge colors:
## Example
```python
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([6,2,13,10])
plt.plot(ypoints, marker ='o', ms =20, mec ='#4CAF50', mfc ='#4CAF50')
plt.show()
The result is shown below:
!(#)
YouTip