Fine controls, such as edge color, interior color, and so on, are possible on markers. It is, for instance, possible to draw a curve with markers of a different color than the color of the curve. In this recipe, we will look at how to have a fine control on a marker's aspect.
We have learned about the optional parameters to set the shape, color, and size of markers. There are plenty of others to play with, as demonstrated in the following script:
import numpy as np import matplotlib.pyplot as plt X = np.linspace(-6, 6, 1024) Y = np.sinc(X) plt.plot(X, Y, linewidth = 3., color = 'k', markersize = 9, markeredgewidth = 1.5, markerfacecolor = '.75', markeredgecolor = 'k', marker = 'o', markevery = 32) plt.show()
The call to pyplot.plot()
is broken over several lines for the readability purpose—one line per optional parameter. The preceding script will produce the following graph: