ScatterGlyph¶
ScatterGlyph draws 2-D point clouds. A per-point values array drives colour through the shared scalar-mapping pipeline (with a matching colorbar); an independent per-point sizes array drives marker area, so colour and size can encode two quantities at once.
In [1]:
Copied!
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from cleopatra.scatter_glyph import ScatterGlyph
rng = np.random.default_rng(0)
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from cleopatra.scatter_glyph import ScatterGlyph
rng = np.random.default_rng(0)
1. Value-coloured points¶
In [2]:
Copied!
x, y = rng.random(150), rng.random(150)
values = x + y # colour by position sum
sg = ScatterGlyph(x, y, values=values, cmap='viridis')
fig, ax, paths = sg.plot(title='Value-coloured points')
x, y = rng.random(150), rng.random(150)
values = x + y # colour by position sum
sg = ScatterGlyph(x, y, values=values, cmap='viridis')
fig, ax, paths = sg.plot(title='Value-coloured points')
2. Colour and size encoding two quantities¶
values drives colour, sizes drives marker area — independently. Set size_legend=True to add a size legend.
In [3]:
Copied!
x, y = rng.random(60), rng.random(60)
values = rng.random(60)
sizes = rng.random(60) * 12
sg = ScatterGlyph(x, y, values=values, sizes=sizes,
size_legend=True, cmap='plasma')
fig, ax, paths = sg.plot(title='Colour + size')
x, y = rng.random(60), rng.random(60)
values = rng.random(60)
sizes = rng.random(60) * 12
sg = ScatterGlyph(x, y, values=values, sizes=sizes,
size_legend=True, cmap='plasma')
fig, ax, paths = sg.plot(title='Colour + size')