PolygonGlyph¶
PolygonGlyph wraps PolyCollection. A per-polygon values array fills and colour-maps the polygons (with a colorbar); with no values or outline_only=True, only the outlines are drawn.
In [1]:
Copied!
import numpy as np
from cleopatra.glyphs.primitives.polygon_glyph import PolygonGlyph
polygons = [
np.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]),
np.array([[1.0, 0.0], [2.0, 0.0], [2.0, 1.0], [1.0, 1.0]]),
np.array([[0.0, 1.0], [1.0, 1.0], [0.5, 2.0]]),
]
import numpy as np
from cleopatra.glyphs.primitives.polygon_glyph import PolygonGlyph
polygons = [
np.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]),
np.array([[1.0, 0.0], [2.0, 0.0], [2.0, 1.0], [1.0, 1.0]]),
np.array([[0.0, 1.0], [1.0, 1.0], [0.5, 2.0]]),
]
1. Value-filled polygons¶
In [2]:
Copied!
values = np.array([10.0, 20.0, 30.0])
pg = PolygonGlyph(polygons, values=values, cmap='YlGnBu')
fig, ax, pc = pg.plot(title='Filled by value')
ax.autoscale()
values = np.array([10.0, 20.0, 30.0])
pg = PolygonGlyph(polygons, values=values, cmap='YlGnBu')
fig, ax, pc = pg.plot(title='Filled by value')
ax.autoscale()
2. Outlines only¶
In [3]:
Copied!
pg = PolygonGlyph(polygons)
fig, ax, pc = pg.plot(outline_only=True, title='Outlines')
ax.autoscale()
pg = PolygonGlyph(polygons)
fig, ax, pc = pg.plot(outline_only=True, title='Outlines')
ax.autoscale()