Commits

Anonymous committed 8f99687

more informative firm plots

Comments (0)

Files changed (1)

src/trial_plots.py

     if step_limit is None:
         step_limit = len(employment_strings[employment_strings.keys()[0]])
     employment_nums = {}
+    all_firms = set()
     for worker_string, firm_string_list in employment_strings.iteritems():
         worker_id = _parse_rep(worker_string)[1]
-        employment_nums[worker_id] = [
+        worker_firms = [
             _parse_rep(firm_string)[1] for firm_string in firm_string_list
         ]
+        all_firms = all_firms.union(worker_firms)
+        employment_nums[worker_id] = worker_firms
     del(employment_strings)
     num_workers = len(employment_nums)
-    per_worker_inc = 0.5/num_workers
     for worker_id in employment_nums:
         employment_nums[worker_id] = [
-            firm + worker_id * per_worker_inc
+            firm + 0.5 * worker_id / num_workers - 0.25
             for firm in employment_nums[worker_id]
         ]
     step_numbers = range(step_limit)
             employment_nums[worker_id][:step_limit],
             color=_hash_to_colour(worker_id)
         )
+    for firm_id in all_firms:
+        plt.plot(
+            step_numbers,
+            [firm_id] * step_limit,
+            color='black',
+            marker='o',
+            linewidth=2,
+        )
+    plt.xlabel('time')
+    plt.ylabel('firm')
+
 
 def wage_versus_previous_wage(world, ax=None):
     if ax is None: