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

Function plot_line

shapely/plotting.py:135–188  ·  view source on GitHub ↗

Plot a (Multi)LineString/LinearRing. Note: this function is experimental, and mainly targeting (interactive) exploration, debugging and illustration purposes. Parameters ---------- line : shapely.LineString or shapely.LinearRing The line to plot. ax : matplotlib Axe

(line, ax=None, add_points=True, color=None, linewidth=2, **kwargs)

Source from the content-addressed store, hash-verified

133
134
135def plot_line(line, ax=None, add_points=True, color=None, linewidth=2, **kwargs):
136 """Plot a (Multi)LineString/LinearRing.
137
138 Note: this function is experimental, and mainly targeting (interactive)
139 exploration, debugging and illustration purposes.
140
141 Parameters
142 ----------
143 line : shapely.LineString or shapely.LinearRing
144 The line to plot.
145 ax : matplotlib Axes, default None
146 The axes on which to draw the plot. If not specified, will get the
147 current active axes or create a new figure.
148 add_points : bool, default True
149 If True, also plot the coordinates (vertices) as points.
150 color : matplotlib color specification
151 Color for the line (edgecolor under the hood) and points.
152 linewidth : float, default 2
153 The line width for the polygon boundary.
154 **kwargs
155 Additional keyword arguments passed to the matplotlib Patch.
156
157 Returns
158 -------
159 Matplotlib artist (PathPatch)
160
161 """
162 from matplotlib.patches import PathPatch
163 from matplotlib.path import Path
164
165 if ax is None:
166 ax = _default_ax()
167
168 if color is None:
169 color = "C0"
170
171 if isinstance(line, shapely.MultiLineString):
172 path = Path.make_compound_path(
173 *[Path(np.asarray(mline.coords)[:, :2]) for mline in line.geoms]
174 )
175 else:
176 path = Path(np.asarray(line.coords)[:, :2])
177
178 patch = PathPatch(
179 path, facecolor="none", edgecolor=color, linewidth=linewidth, **kwargs
180 )
181 ax.add_patch(patch)
182 ax.autoscale_view()
183
184 if add_points:
185 line = plot_points(line, ax=ax, color=color)
186 return patch, line
187
188 return patch
189
190
191def plot_points(geom, ax=None, color=None, marker="o", **kwargs):

Callers 15

test_plot_lineFunction · 0.90
linestring.pyFile · 0.90
rotate.pyFile · 0.90
parallel_offset.pyFile · 0.90
convex_hull.pyFile · 0.90
union.pyFile · 0.90

Calls 2

_default_axFunction · 0.85
plot_pointsFunction · 0.85

Tested by 2

test_plot_lineFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…