Scatter plotsΒΆ

Scatter plots can be obtained by using the scatter method.

import numpy as np
import pylab as plt

np.random.seed(seed=1)
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
z = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radiuses
# Scatter plots with the size as a function of data value
plt.figure()
plt.scatter(x, y, s=z, c='k')
plt.show()
../_images/scatters_2_0.png
# Scatter plots with color as a function of data value
plt.figure()
cs = plt.scatter(x, y, s=600, c=z, 
                 cmap=plt.cm.jet, alpha=0.5, marker='o')
plt.colorbar(cs)
plt.show()
../_images/scatters_3_0.png
# Scatter plots with color and size as a function of data value
plt.figure()
cs = plt.scatter(x, y, s=z, c=z, 
                 cmap=plt.cm.jet, alpha=0.5, marker='o')
plt.colorbar(cs)
plt.show()
../_images/scatters_4_0.png