MCPcopy Index your code
hub / github.com/PyVRP/PyVRP / plot_coordinates

Function plot_coordinates

pyvrp/plotting/plot_coordinates.py:7–51  ·  view source on GitHub ↗

Plots coordinates for clients and depot. Parameters ---------- data Data instance. title Title to add to the plot. ax Axes object to draw the plot on. One will be created if not provided.

(
    data: ProblemData,
    title: str = "Coordinates",
    ax: plt.Axes | None = None,
)

Source from the content-addressed store, hash-verified

5
6
7def plot_coordinates(
8 data: ProblemData,
9 title: str = "Coordinates",
10 ax: plt.Axes | None = None,
11):
12 """
13 Plots coordinates for clients and depot.
14
15 Parameters
16 ----------
17 data
18 Data instance.
19 title
20 Title to add to the plot.
21 ax
22 Axes object to draw the plot on. One will be created if not provided.
23 """
24 if not ax:
25 _, ax = plt.subplots()
26
27 num_locs = data.num_locations
28 x_coords = np.array([data.location(loc).x for loc in range(num_locs)])
29 y_coords = np.array([data.location(loc).y for loc in range(num_locs)])
30
31 # These are the depots
32 kwargs = dict(c="tab:red", marker="*", zorder=3, s=500)
33 ax.scatter(
34 x_coords[: data.num_depots],
35 y_coords[: data.num_depots],
36 label="Depot",
37 **kwargs,
38 )
39
40 ax.scatter(
41 x_coords[data.num_depots :],
42 y_coords[data.num_depots :],
43 s=50,
44 label="Clients",
45 )
46
47 ax.grid(color="grey", linestyle="solid", linewidth=0.2)
48
49 ax.set_title(title)
50 ax.set_aspect("equal", "datalim")
51 ax.legend(frameon=False, ncol=2)

Callers 1

plot_instanceFunction · 0.90

Calls 1

locationMethod · 0.80

Tested by

no test coverage detected