chiark / gitweb /
m.plots: make it possible to hide particular extra labels.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 12 Sep 2018 10:39:42 +0000 (12:39 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 13 Sep 2018 13:54:13 +0000 (15:54 +0200)
doc/plugins/plots-and-graphs.rst
pelican-plugins/m/plots.py
pelican-plugins/m/test/plots/page-travis-broken-matplotlib-seed.html
pelican-plugins/m/test/plots/page.html
pelican-plugins/m/test/plots/page.rst

index ce4816bd36f748c17c2c95d3f218dd3ae8f63a14..b2ac33941acc7641315797a1500d4839e83e8909 100644 (file)
@@ -113,11 +113,14 @@ labels. Hovering over the bars will show the concrete value in a title.
 It's also optionally possible to add error bars using :rst:`:error:` and
 configure bar colors using :rst:`:colors:`. The colors correspond to m.css
 `color classes <{filename}/css/components.rst#colors>`_ and you can either
-use one color for all or one for each value, separated by whitespace. It's
-possible to add an extra line of labels using :rst:`:labels_extra:`. Bar chart
+use one color for all or one for each value, separated by whitespace. Bar chart
 height is calculated automatically based on amount of values, you can adjust
 the bar height using :rst:`:bar_height:`. Default value is :py:`0.4`.
 
+It's possible to add an extra line of labels using :rst:`:labels_extra:`.
+Again, there should be as many entries as primary labels and values. To omit an extra label for a value, specify it as the :abbr:`reST <reStructuredText>`
+comment :rst:`..`.
+
 .. code-figure::
 
     .. code:: rst
@@ -133,7 +136,7 @@ the bar height using :rst:`:bar_height:`. Default value is :py:`0.4`.
                 15 modules
                 60 modules
                 200 modules
-                for comparison
+                ..
             :units: µs
             :values: 15.09 84.98 197.13 934.27
             :errors: 0.74 3.65 9.45 25.66
@@ -151,7 +154,7 @@ the bar height using :rst:`:bar_height:`. Default value is :py:`0.4`.
             15 modules
             60 modules
             200 modules
-            for comparison
+            ..
         :units: µs
         :values: 15.09 84.98 197.13 934.27
         :errors: 0.74 3.65 9.45 25.66
index 42f95dc00dfa1436b366708baf04d43a9d03a393..1469ca7840e74e886650670dfee81b7e86457b85 100644 (file)
@@ -203,8 +203,9 @@ class Plot(rst.Directive):
         # with first having the second line empty and second having the first
         # line empty.
         if labels_extra:
-            ax.set_yticklabels([y + '\n' for y in labels])
+            ax.set_yticklabels([y + ('' if labels_extra[i] == '..' else '\n') for i, y in enumerate(labels)])
             for i, label in enumerate(ax.get_yticklabels()):
+                if labels_extra[i] == '..': continue
                 ax.text(0, i + 0.05, '\n' + labels_extra[i],
                         va='center', ha='right',
                         transform=label.get_transform(), color='#cafe0b')
index c676996e20b24efc24fd08b3f0c2bd9d3aca1029..62592f133899da7f72f37e75839aa963cf168d5e 100644 (file)
@@ -281,8 +281,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
       </g>
      </g>
      <g id="text_10">
-      <text class="m-label" transform="translate(11.88 98.893391)">February</text>
-      <text class="m-label" transform="translate(61.216719 111.210984)"/>
+      <text class="m-label" style="text-anchor:end;" transform="rotate(-0, 61.216719, 105.052188)" x="61.216719" y="105.052188">February</text>
      </g>
     </g>
     <g id="ytick_3">
@@ -324,14 +323,10 @@ div.m-plot svg { font-family: DejaVu Sans; }
     <text class="m-label m-dim" transform="translate(3.454687 64.963699)">a paradise</text>
    </g>
    <g id="text_13">
-    <text class="m-label m-dim" transform="translate(61.216719 100.123429)"/>
-    <text class="m-label m-dim" transform="translate(34.866563 112.441022)">okay</text>
-   </g>
-   <g id="text_14">
     <text class="m-label m-dim" transform="translate(61.216719 147.600752)"/>
     <text class="m-label m-dim" transform="translate(36.954844 159.918346)">hell!</text>
    </g>
-   <g id="text_15">
+   <g id="text_14">
     <text class="m-title" style="text-anchor:middle;" transform="rotate(-0, 313.34957, 21.757969)" x="313.34957" y="21.757969">A plot with separate colors, extra labels, error bars and custom height</text>
    </g>
   </g>
index 5bf4c214612d028ed9586887722edb0d458ec253..896edd1f0ba81cb3726dc27a8be47953827b9d78 100644 (file)
@@ -281,8 +281,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
       </g>
      </g>
      <g id="text_10">
-      <text class="m-label" transform="translate(11.88 98.893391)">February</text>
-      <text class="m-label" transform="translate(61.216719 111.210984)"/>
+      <text class="m-label" style="text-anchor:end;" transform="rotate(-0, 61.216719, 105.052188)" x="61.216719" y="105.052188">February</text>
      </g>
     </g>
     <g id="ytick_3">
@@ -324,14 +323,10 @@ div.m-plot svg { font-family: DejaVu Sans; }
     <text class="m-label m-dim" transform="translate(3.454687 64.963699)">a paradise</text>
    </g>
    <g id="text_13">
-    <text class="m-label m-dim" transform="translate(61.216719 100.123429)"/>
-    <text class="m-label m-dim" transform="translate(34.866563 112.441022)">okay</text>
-   </g>
-   <g id="text_14">
     <text class="m-label m-dim" transform="translate(61.216719 147.600752)"/>
     <text class="m-label m-dim" transform="translate(36.954844 159.918346)">hell!</text>
    </g>
-   <g id="text_15">
+   <g id="text_14">
     <text class="m-title" style="text-anchor:middle;" transform="rotate(-0, 313.34957, 21.757969)" x="313.34957" y="21.757969">A plot with separate colors, extra labels, error bars and custom height</text>
    </g>
   </g>
index d0925f3c08d25e288ead30af6b7ea5867fdca1d5..295429a562923055293908399014e5f670fffeb0 100644 (file)
@@ -27,7 +27,7 @@ predictable rendering on the CIs.
         March
     :labels_extra:
         a paradise
-        okay
+        ..
         hell!
     :units: Mondays
     :values: 3 4 5