فهرست منبع

Add --size cmdline arg to labours

Vadim Markovtsev 7 سال پیش
والد
کامیت
2ec5948cc0
4فایلهای تغییر یافته به همراه14 افزوده شده و 8 حذف شده
  1. 4 3
      README.md
  2. BIN
      doc/emberjs_people.png
  3. BIN
      doc/wireshark_people.png
  4. 10 5
      labours.py

+ 4 - 3
README.md

@@ -115,8 +115,8 @@ The sequence of developers is stored in `people_sequence` YAML node.
 
 #### Code ownership
 
-![Wireshark top 20 code ownership](doc/wireshark_people.png)
-<p align="center">Wireshark top 20 devs - code ownership</p>
+![Ember.js top 20 code ownership](doc/emberjs_people.png)
+<p align="center">Ember.js top 20 devs - code ownership</p>
 
 ```
 hercules -people [-people-dict=/path/to/identities]
@@ -171,11 +171,12 @@ hercules -people https://github.com/... | python3 fix_yaml_unicode.py | python3
 These options affects all plots:
 
 ```
-python3 labours.py [--style=white|black] [--backend=]
+python3 labours.py [--style=white|black] [--backend=] [--size=Y,X]
 ```
 
 `--style` changes the background to be either white ("black" foreground) or black ("white" foreground).
 `--backend` chooses the Matplotlib backend.
+`--size` sets the size of the figure in inches. The default is `12,9`.
 
 (required in macOS) you can pin the default Matplotlib backend with
 

BIN
doc/emberjs_people.png


BIN
doc/wireshark_people.png


+ 10 - 5
labours.py

@@ -34,6 +34,7 @@ def parse_args():
     parser.add_argument("--backend", help="Matplotlib backend to use.")
     parser.add_argument("--style", choices=["black", "white"], default="black",
                         help="Plot's general color scheme.")
+    parser.add_argument("--size", help="Axes' size in inches, for example \"12,9\"")
     parser.add_argument("--relative", action="store_true",
                         help="Occupy 100%% height for every measurement.")
     parser.add_argument("--couples-tmp-dir", help="Temporary directory to work with couples.")
@@ -209,8 +210,12 @@ def load_people(header, sequence, contents):
     return sequence, people, date_range_sampling, last
 
 
-def apply_plot_style(figure, axes, legend, style, text_size):
-    figure.set_size_inches(12, 9)
+def apply_plot_style(figure, axes, legend, style, text_size, axes_size):
+    if axes_size is None:
+        axes_size = (12, 9)
+    else:
+        axes_size = tuple(float(p) for p in axes_size.split(","))
+    figure.set_size_inches(*axes_size)
     for side in ("bottom", "top", "left", "right"):
         axes.spines[side].set_color(style)
     for axis in (axes.xaxis, axes.yaxis):
@@ -269,7 +274,7 @@ def plot_burndown(args, target, name, matrix, date_range_sampling, labels, granu
     legend = pyplot.legend(loc=legend_loc, fontsize=args.text_size)
     pyplot.ylabel("Lines of code")
     pyplot.xlabel("Time")
-    apply_plot_style(pyplot.gcf(), pyplot.gca(), legend, args.style, args.text_size)
+    apply_plot_style(pyplot.gcf(), pyplot.gca(), legend, args.style, args.text_size, args.size)
     pyplot.xlim(date_range_sampling[0], date_range_sampling[-1])
     locator = pyplot.gca().xaxis.get_major_locator()
     # set the optimal xticks locator
@@ -366,7 +371,7 @@ def plot_churn_matrix(args, repo, people, matrix):
     ax.set_xticks(numpy.arange(0.5, matrix.shape[1] + 0.5), minor=True)
     ax.set_yticks(numpy.arange(0.5, matrix.shape[0] + 0.5), minor=True)
     ax.grid(which="minor")
-    apply_plot_style(fig, ax, None, args.style, args.text_size)
+    apply_plot_style(fig, ax, None, args.style, args.text_size, args.size)
     if not args.output:
         pos1 = ax.get_position()
         pos2 = (pos1.x0 + 0.245, pos1.y0 - 0.1, pos1.width * 0.9, pos1.height * 0.9)
@@ -407,7 +412,7 @@ def plot_people(args, repo, names, people, date_range, last):
     else:
         legend_loc = 2
     legend = pyplot.legend(loc=legend_loc, fontsize=args.text_size)
-    apply_plot_style(pyplot.gcf(), pyplot.gca(), legend, args.style, args.text_size)
+    apply_plot_style(pyplot.gcf(), pyplot.gca(), legend, args.style, args.text_size, args.size)
     if args.mode == "all":
         output = get_plot_path(args.output, "people")
     else: