File: example_density.py

package info (click to toggle)
mpl-scatter-density 0.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,448 kB
  • sloc: python: 661; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import numpy as np

import matplotlib.pyplot as plt

# The following is needed to register the axes
import mpl_scatter_density  # noqa

from astropy.visualization import LogStretch
from astropy.visualization.mpl_normalize import ImageNormalize

norm = ImageNormalize(vmin=0., vmax=1000, stretch=LogStretch())

ax = plt.subplot(1, 1, 1, projection='scatter_density')

n = 100000000
x = np.random.normal(0.5, 0.3, n)
y = np.random.normal(0.5, 0.3, n)

ax.scatter_density(x, y, cmap='viridis', norm=norm)

plt.show()