As seen in the previous recipe, we can control the style of markers; controlling their size also works along the same lines. In this recipe, we are going to see how to control marker sizes.
A marker's size is controlled in the same way as other marker attributes, with a dedicated optional parameter as shown in the following script:
import numpy as np import matplotlib.pyplot as plt A = np.random.standard_normal((100, 2)) A += np.array((-1, -1)) B = np.random.standard_normal((100, 2)) B += np.array((1, 1)) plt.scatter(B[:,0], B[:,1], c = 'k', s = 100.) plt.scatter(A[:,0], A[:,1], c = 'w', s = 25.) plt.show()
The preceding script produces the following graph:
In this example, we display two sets of points of different sizes. The marker's size is set by the parameter s
for pyplot.scatter()
. Oddly enough, it sets the surface area of a marker and not its radius.
Because the sizes are the actual surface areas and not the radii, they follow a quadratic progression...