لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

# Python Data Science Matplotlib Markers 'o' Circle, '*' Star, '.' Point, ',' Pixel, 'x' X,

Markers are keyword argument used to emphasize each point with a specified marker.

Example 1: Mark each point with a circle:

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o')
plt.show()

the output will be

Example 2: In the same example mark each point with a star: Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o')
plt.show()

the output will be

# Marker References

You can choose any of the followings.

```
Marker	Description
'o'	Circle
'*'	Star
'.'	Point
','	Pixel
'x'	X
'X'	X (filled)
'+'	Plus
'P'	Plus (filled)
's'	Square
'D'	Diamond
'd'	Diamond (thin)
'p'	Pentagon
'H'	Hexagon
'h'	Hexagon
'v'	Triangle Down
'^'	Triangle Up
'<'	Triangle Left
'>'	Triangle Right
'1'	Tri Down
'2'	Tri Up
'3'	Tri Left
'4'	Tri Right
'|'	Vline
'_'	Hline
```

# Format Strings fmt

One can also use the shortcut string notation parameter to specify the marker.

This parameter is also called fmt, and is written with this syntax: marker|line|color

Example 3: Mark each point with a circle.

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, 'o:r')
plt.show()

the output will be

# Line References

You can choose any of the line values..

Line Syntax Description

'-' ------>Solid line

':' ------>Dotted line

'--' ------>Dashed line

'-.' ------>Dashed/dotted line

Please note that If you leave out the line value in the fmt parameter, no line will be plotted.

# Color Reference:

The short color value can be one of the following.

Color Syntax ------Description
'r' -------------->Red

'g' -------------->Green

'b' -------------->Blue

'c' -------------->Cyan

'm' -------------->Magenta

'y' -------------->Yellow

'k' -------------->Black

'w' --------------> White

# Marker Size

The keyword argument markersize or the shorter version, ms is used to set the size of the markers.

Example 4: Set the size of the markers to 20

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o', ms = 20)
plt.show()

the output will be

# Marker Color

The keyword argument markeredgecolor or the shorter mec is used to set the color of the edge of the markers.

Example 5: Set the EDGE color to red

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o', ms = 20, mec = 'r')
plt.show()

the output will be

# Marker Face Color

One can use the keyword argument markerfacecolor or the shorter mfc to set the color inside the edge of the markers.

Example 6: Set the FACE color to red.

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o', ms = 20, mfc = 'r')
plt.show()

the output will be

# Using both the mec & mfc arguments to color the entire marker.

Example 7: Set the color of both the edge and the face to red.

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o', ms = 20, mec = 'r', mfc = 'r')
plt.show()

the output will be

Example 8: Mark each point with a beautiful green color

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o', ms = 20, mec = '#4CAF50', mfc = '#4CAF50')
plt.show()

the output will be

# Using Any of the 140 Supported Color Names

Example 8: Mark each point with a the color name orange

Code

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o', ms = 20, mec = 'orange', mfc = 'orange')
plt.show()

the output will be