Using custom characters as markers

Matplotlib supports the use of custom characters as markers, which now include mathtext and emoji. To use characters as custom markers, we concatenate two dollar signs '$', each in front of and behind the character, and we pass them as the marker parameter.
The notations starting with a backslash '', such as 'clubsuit', are in mathtext, which will be introduced later in this chapter (in the text and annotations section).

Here is an example of a scatter plot of markers in mathematical symbols and an emoji:

import matplotlib.pyplot as plt
from matplotlib.lines import Line2D

custom_markers = ['$'+x+'$' for x in ['$','\%','clubsuit','sigma','']]
for i,marker in enumerate(custom_markers):
plt.scatter(i%10,i,marker=marker,s=500) # plot each of the markers in size of 100
plt.show()

As seen from the following figure, we have successfully used symbols, a Greek alphabet, as well as an emoji as custom markers in a scatter plot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.129.65