matplotlib offers a large variety of marker shapes. But you might not find something that suits your specific need. For instance, you might wish to use an animal silhouette, a company's logo, and so on. In this recipe, we are going to see how to define our own marker shapes.
matplotlib describes shapes as a path—a sequence of points linked together. Thus, to define our own marker shapes, we have to provide a sequence of points. In the following script example, we will define a cross-like shape:
import numpy as np import matplotlib.path as mpath from matplotlib import pyplot as plt shape_description = [ ( 1., 2., mpath.Path.MOVETO), ( 1., 1., mpath.Path.LINETO), ( 2., 1., mpath.Path.LINETO), ( 2., -1., mpath.Path.LINETO), ( 1., -1., mpath.Path.LINETO), ( 1., -2., mpath.Path.LINETO), (-1., -2., mpath.Path.LINETO), (-1., -1., mpath.Path.LINETO), (-2., -1., mpath.Path.LINETO), (-2., 1., mpath.Path.LINETO), (-1., 1., mpath.Path...