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
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
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
# 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')
</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">
<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>
</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">
<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>
March
:labels_extra:
a paradise
- okay
+ ..
hell!
:units: Mondays
:values: 3 4 5