Pelican plugins » Plots

Al­lows you to ren­der plots di­rect­ly from da­ta spec­i­fied in­line in the page source. Sim­i­lar­ly to math ren­der­ing, the plots are ren­dered to a SVG that’s em­bed­ded di­rect­ly in the HTML markup.

How to use

Down­load the m/ file, put it in­clud­ing the m/ di­rec­to­ry in­to one of your PLUGIN_PATHS and add m.plots pack­age to your PLUGINS in

PLUGINS += ['m.plots']
M_PLOTS_FONT = 'Source Sans Pro'

Set M_PLOTS_FONT to a font that match­es your CSS theme (it’s Source Sans Pro for builtin m.css themes), note that you need to have the font in­stalled on your sys­tem, oth­er­wise it will fall back to what­ev­er sys­tem font it finds in­stead (for ex­am­ple De­jaVu Sans) and the out­put won’t look as ex­pect­ed. In ad­di­tion you need the Mat­plotlib li­brary in­stalled. Get it via pip or your dis­tri­bu­tion pack­age man­ag­er:

pip3 install matplotlib

The plug­in pro­duces SVG plots that make use of the CSS plot styling.

Bar graphs

Cur­rent­ly the on­ly sup­port­ed plot type is a hor­i­zon­tal bar graph, de­not­ed by :type: hbar:

.. plot:: Fastest animals
    :type: barh
    :units: km/h
    :values: 109.4 88.5 88 80.5
109.4 km/h 88.5 km/h 88.0 km/h 80.5 km/h 0 20 40 60 80 100 km/h Cheetah Pronghorn Springbok Wildebeest Fastest animals

The mul­ti-line :labels: op­tion con­tain val­ue la­bels, one per line. You can spec­i­fy unit la­bel us­ing :units:, par­tic­u­lar val­ues go in­to :values: sep­a­rat­ed by white­space, there should me as many val­ues as la­bels. Hov­er­ing over the bars will show the con­crete val­ue in a ti­tle.

It’s al­so op­tion­al­ly pos­si­ble to add er­ror bars us­ing :error: and con­fig­ure bar col­ors us­ing :colors:. The col­ors cor­re­spond to m.css col­or class­es and you can ei­ther use one col­or for all or one for each val­ue, sep­a­rat­ed by white­space. It’s pos­si­ble to add an ex­tra line of la­bels us­ing :labels_extra:. Bar graph height is cal­cu­lat­ed au­to­mat­i­cal­ly based on amount of val­ues, you can ad­just the bar height us­ing :bar_height:. De­fault val­ue is 0.4.

.. plot:: Runtime cost
    :type: barh
        Ours minimal
        Ours default
        3rd party
        Full setup
        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
    :colors: success info danger dim
    :bar_height: 0.6
15.09 ± 0.74 µs 84.98 ± 3.65 µs 197.13 ± 9.45 µs 934.27 ± 25.66 µs 0 200 400 600 800 1000 µs Ours minimal Ours default 3rd party Full setup 15 modules 60 modules 200 modules for comparison Runtime cost