graphs: make graphs with lots of packages nicer to look at
authorYann E. MORIN <yann.morin.1998@free.fr>
Sun, 13 Apr 2014 20:42:42 +0000 (22:42 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 14 Apr 2014 20:13:04 +0000 (22:13 +0200)
Some magic numbers obtained with trial-and-error and successive
iterations, to eventually get a nice graph.

[Thomas: remove excessive spaces in expressions.]

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
support/scripts/graph-build-time

index 00c2349faf4763319e849ecbb98a140bde9c88d8..45f94353f350932bae26bc3e845a2dcad0e9fb28 100755 (executable)
@@ -126,12 +126,17 @@ def pkg_histogram(data, output, order="build"):
     # Draw the package names
     plt.xticks(ind + .6, [ p.name for p in data ], rotation=-60, rotation_mode="anchor", fontsize=8, ha='left')
 
-    # Adjust size of graph (double the width)
-    sz = plt.gcf().get_size_inches()
-    plt.gcf().set_size_inches(sz[0] * 2, sz[1])
-
-    # Add more space for the package names at the bottom
-    plt.gcf().subplots_adjust(bottom=0.2)
+    # Adjust size of graph depending on the number of packages
+    # Ensure a minimal size twice as the default
+    # Magic Numbers do Magic Layout!
+    ratio = max(((n_pkgs + 10) / 48, 2))
+    borders = 0.1 / ratio
+    sz = plt.gcf().get_figwidth()
+    plt.gcf().set_figwidth(sz * ratio)
+
+    # Adjust space at borders, add more space for the
+    # package names at the bottom
+    plt.gcf().subplots_adjust(bottom=0.2, left=borders, right=1-borders)
 
     # Remove ticks in the graph for each package
     axes = plt.gcf().gca()