Florian 7 年 前
コミット
6b7783cf2f
2 ファイル変更5 行追加5 行削除
  1. 3 4
      plan_gen/plan_gen.py
  2. 2 1
      plan_gen/plan_visualizer.py

+ 3 - 4
plan_gen/plan_gen.py

@@ -101,10 +101,9 @@ def rand_node_xy(nodes, clusters, densities):
     clusters = clusters.flatten()
     densities = densities.flatten()
     cluster = np.random.choice(clusters, p=densities/sum(densities))
-    if cluster is None:
-        node = nodes[np.random.randint(len(nodes))]
-    else:
-        node = cluster[np.random.randint(len(cluster))]
+    while cluster is None:
+        cluster = np.random.choice(clusters, p=densities/sum(densities))
+    node = cluster[np.random.randint(len(cluster))]
     return (node.get('x'), node.get('y'))
 
 def rand_person(nodes, clusters, h_dens, w_dens):

+ 2 - 1
plan_gen/plan_visualizer.py

@@ -54,13 +54,14 @@ if __name__ == '__main__':
     X_TICKS = np.arange(MIN_X, MAX_X, (MAX_X - MIN_X) / NB_CLUSTERS)
     Y_TICKS = np.arange(MIN_Y, MAX_Y, (MAX_Y - MIN_Y) / NB_CLUSTERS)
     TICK_LABELS = list(range(NB_CLUSTERS))
-    AX.set_title('Agents by nodes distribution (total: {} agents)'.format(len(PERSONS)))
+    AX.set_title('Number of agents by nodes (total: {} agents)'.format(len(PERSONS)))
     AX.set_xlim(MIN_X, MAX_X)
     AX.set_ylim(MIN_Y, MAX_Y)
     AX.set_xticks(X_TICKS)
     AX.set_yticks(Y_TICKS)
     AX.set_xticklabels(TICK_LABELS)
     AX.set_yticklabels(TICK_LABELS)
+    AX.tick_params(labelsize=5)
     AX.grid(True)
     plt.colorbar(SC)
     plt.show()