MCPcopy Index your code
hub / github.com/shapely/shapely / plot_polygon

Function plot_polygon

shapely/plotting.py:62–132  ·  view source on GitHub ↗

Plot a (Multi)Polygon. Note: this function is experimental, and mainly targeting (interactive) exploration, debugging and illustration purposes. Parameters ---------- polygon : shapely.Polygon or shapely.MultiPolygon The polygon to plot. ax : matplotlib Axes, defaul

(
    polygon,
    ax=None,
    add_points=True,
    color=None,
    facecolor=None,
    edgecolor=None,
    linewidth=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

60
61
62def plot_polygon(
63 polygon,
64 ax=None,
65 add_points=True,
66 color=None,
67 facecolor=None,
68 edgecolor=None,
69 linewidth=None,
70 **kwargs,
71):
72 """Plot a (Multi)Polygon.
73
74 Note: this function is experimental, and mainly targeting (interactive)
75 exploration, debugging and illustration purposes.
76
77 Parameters
78 ----------
79 polygon : shapely.Polygon or shapely.MultiPolygon
80 The polygon to plot.
81 ax : matplotlib Axes, default None
82 The axes on which to draw the plot. If not specified, will get the
83 current active axes or create a new figure.
84 add_points : bool, default True
85 If True, also plot the coordinates (vertices) as points.
86 color : matplotlib color specification
87 Color for both the polygon fill (face) and boundary (edge). By default,
88 the fill is using an alpha of 0.3. You can specify `facecolor` and
89 `edgecolor` separately for greater control.
90 facecolor : matplotlib color specification
91 Color for the polygon fill.
92 edgecolor : matplotlib color specification
93 Color for the polygon boundary.
94 linewidth : float
95 The line width for the polygon boundary.
96 **kwargs
97 Additional keyword arguments passed to the matplotlib Patch.
98
99 Returns
100 -------
101 Matplotlib artist (PathPatch), if `add_points` is false.
102 A tuple of Matplotlib artists (PathPatch, Line2D), if `add_points` is true.
103
104 """
105 from matplotlib import colors
106
107 if ax is None:
108 ax = _default_ax()
109
110 if color is None:
111 color = "C0"
112 color = colors.to_rgba(color)
113
114 if facecolor is None:
115 facecolor = list(color)
116 facecolor[-1] = 0.3
117 facecolor = tuple(facecolor)
118
119 if edgecolor is None:

Callers 15

test_plot_polygonFunction · 0.90
test_plot_multipolygonFunction · 0.90
multipolygon.pyFile · 0.90
polygon.pyFile · 0.90
difference.pyFile · 0.90
triangulate.pyFile · 0.90

Calls 3

_default_axFunction · 0.85
patch_from_polygonFunction · 0.85
plot_pointsFunction · 0.85

Tested by 4

test_plot_polygonFunction · 0.72
test_plot_multipolygonFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…