-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_nodes.py
34 lines (26 loc) · 858 Bytes
/
plot_nodes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import matplotlib.pyplot as plt
def plot_nodes(nodes, fig=None, fmt='bo'):
if fig is None:
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.plot(nodes[:, 0], nodes[:, 1], fmt)
return fig
def plot_gridlines(boundaries, fig):
ax = fig.add_subplot(111)
for b in boundaries:
ax.axvline(b, color='gray', alpha=0.5)
ax.axhline(b, color='gray', alpha=0.5)
return fig
def plot_nodes_weighted(nodes, masses, fig=None, colour='b'):
if fig is None:
fig = plt.figure(1)
ax = fig.add_subplot(111)
min_masses = min(masses)
max_masses = max(masses)
print(max_masses)
print(min_masses)
marker_size = (masses - min_masses) / (max_masses - min_masses)
marker_size *= 50
marker_size += 1
ax.scatter(nodes[:, 0], nodes[:, 1], color=colour, s=marker_size)
return fig