1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/usr/bin/python3
import warnings
import numpy as np
import matplotlib.pyplot as plt
import mpl_scatter_density # noqa
warnings.filterwarnings("ignore")
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='scatter_density')
n = 10000000
x = np.random.normal(0.5, 0.3, n)
y = np.random.normal(0.5, 0.3, n)
ax.scatter_density(x, y, color='red')
x = np.random.normal(1.0, 0.2, n)
y = np.random.normal(0.6, 0.2, n)
ax.scatter_density(x, y, color='blue')
ax.set_xlim(-0.5, 1.5)
ax.set_ylim(-0.5, 1.5)
fig.savefig('double.png')
|