@@ -239,12 +239,12 @@ <h2 id="toc-title">On this page</h2>
239239< h1 class ="hidden unlisted unnumbered "> Setup</ h1 >
240240< section id ="parameters " class ="level2 ">
241241< h2 class ="anchored " data-anchor-id ="parameters "> Parameters</ h2 >
242- < div id ="f2501b6d " class ="cell " data-execution_count ="1 ">
242+ < div id ="636145f3 " class ="cell " data-execution_count ="1 ">
243243< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="cb1 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb1-1 "> < a href ="#cb1-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="im "> from</ span > pyprojroot < span class ="im "> import</ span > here</ span >
244244< span id ="cb1-2 "> < a href ="#cb1-2 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="im "> import</ span > mpl_fontkit < span class ="im "> as</ span > fk</ span >
245245< span id ="cb1-3 "> < a href ="#cb1-3 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="im "> from</ span > brand_yml < span class ="im "> import</ span > Brand</ span > </ code > </ pre > </ div > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ div >
246246</ div >
247- < div id ="0c9ee644 " class ="cell " data-tags ="["parameters"] " data-execution_count ="2 ">
247+ < div id ="c67d0075 " class ="cell " data-tags ="["parameters"] " data-execution_count ="2 ">
248248< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="cb2 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb2-1 "> < a href ="#cb2-1 " aria-hidden ="true " tabindex ="-1 "> </ a > LABOUR_DATA_FILE < span class ="op "> =</ span > here() < span class ="op "> /</ span > < span class ="st "> "data"</ span > < span class ="op "> /</ span > < span class ="st "> "14100355.csv"</ span > </ span >
249249< span id ="cb2-2 "> < a href ="#cb2-2 " aria-hidden ="true " tabindex ="-1 "> </ a > FIGURE_THEME_SIZE < span class ="op "> =</ span > (< span class ="dv "> 9</ span > , < span class ="dv "> 5</ span > )</ span >
250250< span id ="cb2-3 "> < a href ="#cb2-3 " aria-hidden ="true " tabindex ="-1 "> </ a > FILTER_YEAR < span class ="op "> =</ span > (< span class ="dv "> 2018</ span > , < span class ="dv "> 2025</ span > )</ span >
@@ -262,7 +262,7 @@ <h2 class="anchored" data-anchor-id="parameters">Parameters</h2>
262262</ section >
263263< section id ="libraries " class ="level2 ">
264264< h2 class ="anchored " data-anchor-id ="libraries "> Libraries</ h2 >
265- < div id ="3a9f74ae " class ="cell " data-execution_count ="3 ">
265+ < div id ="6fc4703b " class ="cell " data-execution_count ="3 ">
266266< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="cb4 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb4-1 "> < a href ="#cb4-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="im "> from</ span > labourcan.data_processing < span class ="im "> import</ span > (</ span >
267267< span id ="cb4-2 "> < a href ="#cb4-2 " aria-hidden ="true " tabindex ="-1 "> </ a > read_labourcan,</ span >
268268< span id ="cb4-3 "> < a href ="#cb4-3 " aria-hidden ="true " tabindex ="-1 "> </ a > calculate_centered_rank,</ span >
@@ -281,7 +281,7 @@ <h2 class="anchored" data-anchor-id="libraries">Libraries</h2>
281281< span id ="cb4-16 "> < a href ="#cb4-16 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="im "> import</ span > matplotlib.pyplot < span class ="im "> as</ span > plt</ span >
282282< span id ="cb4-17 "> < a href ="#cb4-17 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="im "> import</ span > re</ span > </ code > </ pre > </ div > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ div >
283283</ div >
284- < div id ="975baca8 " class ="cell " data-execution_count ="4 ">
284+ < div id ="3f058dd9 " class ="cell " data-execution_count ="4 ">
285285< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="cb5 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb5-1 "> < a href ="#cb5-1 " aria-hidden ="true " tabindex ="-1 "> </ a > labour < span class ="op "> =</ span > read_labourcan(LABOUR_DATA_FILE)</ span >
286286< span id ="cb5-2 "> < a href ="#cb5-2 " aria-hidden ="true " tabindex ="-1 "> </ a > </ span >
287287< span id ="cb5-3 "> < a href ="#cb5-3 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="co "> # Remove Aggregated Rows</ span > </ span >
@@ -336,7 +336,7 @@ <h2 class="anchored" data-anchor-id="libraries">Libraries</h2>
336336< span id ="cb5-52 "> < a href ="#cb5-52 " aria-hidden ="true " tabindex ="-1 "> </ a > ]</ span > </ code > </ pre > </ div > < button title ="Copy to Clipboard " class ="code-copy-button "> < i class ="bi "> </ i > </ button > </ div >
337337</ div >
338338< p > Stats</ p >
339- < div id ="34cc7f8e " class ="cell " data-execution_count ="5 ">
339+ < div id ="b750f5d2 " class ="cell " data-execution_count ="5 ">
340340< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="cb6 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb6-1 "> < a href ="#cb6-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="kw "> def</ span > make_subtitle_for_industry(df, INDUSTRY):</ span >
341341< span id ="cb6-2 "> < a href ="#cb6-2 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="co "> # Define offsets</ span > </ span >
342342< span id ="cb6-3 "> < a href ="#cb6-3 " aria-hidden ="true " tabindex ="-1 "> </ a > offsets < span class ="op "> =</ span > {</ span >
@@ -392,7 +392,7 @@ <h2 class="anchored" data-anchor-id="libraries">Libraries</h2>
392392< h1 > Horizontal legend with horizontal legend text</ h1 >
393393< p > Initially I wanted a horizontal legend for the colors. But in order to remove the whitespace between keys, I discovered that the text needs to be smaller than the legend keys, otherwise they “push” the legend keys apart in uneven manner. I attempted to (< em > unsuccesfully</ em > ) address this by making the legend text small, eliminating as much text as possible (e.g. removing the “%” characters for < code > -0.50</ code > and < code > 0.50</ code > ), and lastly increasing the legend key size.</ p >
394394< p > But it still didn’t really work out the way I hoped, so I stuck with a vertical legend instead.</ p >
395- < div id ="10b9b01a " class ="cell " data-execution_count ="6 ">
395+ < div id ="b3eb5a01 " class ="cell " data-execution_count ="6 ">
396396< div class ="cell-output cell-output-display ">
397397< div >
398398< figure class ="figure ">
@@ -407,7 +407,7 @@ <h1>Composing in plotnine is not like R’s patchwork</h1>
407407< p > I wanted to add a line plot of employment numbers to the heatmap. Given the similar syntax in plotnine’s < a href ="https://plotnine.org/guide/plot-composition.html "> compose</ a > to R’s < a href ="https://patchwork.data-imaginist.com/ "> patchwork</ a > , I thought the behaviour would be similar.</ p >
408408< p > One discrepancy is that there is no way to specify the relative size of component plots. But this might be addressed very soon < a href ="https://github.com/has2k1/plotnine/pull/980 "> #980</ a > </ p >
409409< p > It is possible to (rather labourously) pad plots by using < code > plot_spacer</ code > s, which I attemp unsuccessfully below:</ p >
410- < div id ="545cdcf1 " class ="cell " data-execution_count ="7 ">
410+ < div id ="efca8456 " class ="cell " data-execution_count ="7 ">
411411< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="annotated-cell-6 "> < pre class ="sourceCode python code-annotation-code code-with-copy "> < code class ="sourceCode python "> < span id ="annotated-cell-6-1 "> < a href ="#annotated-cell-6-1 " aria-hidden ="true " tabindex ="-1 "> </ a > INDUSTRY < span class ="op "> =</ span > < span class ="st "> "Total employed, all industries"</ span > </ span >
412412< span id ="annotated-cell-6-2 "> < a href ="#annotated-cell-6-2 " aria-hidden ="true " tabindex ="-1 "> </ a > plot_data_subsetted < span class ="op "> =</ span > labour_processed_cutted.< span class ="bu "> filter</ span > (pl.col(< span class ="st "> "Industry"</ span > ) < span class ="op "> ==</ span > INDUSTRY)</ span >
413413< span id ="annotated-cell-6-3 "> < a href ="#annotated-cell-6-3 " aria-hidden ="true " tabindex ="-1 "> </ a > </ span >
@@ -480,7 +480,7 @@ <h1>Composing in plotnine is not like R’s patchwork</h1>
480480</ div >
481481< p > The x axes don’t automatically line up</ p >
482482< p > This can be fixed by ensuring < code > expand</ code > and the < code > limits</ code > is the same:</ p >
483- < div id ="16a59aaa " class ="cell " data-execution_count ="8 ">
483+ < div id ="4d7e8b8f " class ="cell " data-execution_count ="8 ">
484484< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="cb8 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb8-1 "> < a href ="#cb8-1 " aria-hidden ="true " tabindex ="-1 "> </ a > Stack([plot_highlight_industry, line_plot]) < span class ="op "> &</ span > scale_x_datetime(</ span >
485485< span id ="cb8-2 "> < a href ="#cb8-2 " aria-hidden ="true " tabindex ="-1 "> </ a > expand< span class ="op "> =</ span > (< span class ="dv "> 0</ span > , < span class ="dv "> 0</ span > )</ span >
486486< span id ="cb8-3 "> < a href ="#cb8-3 " aria-hidden ="true " tabindex ="-1 "> </ a > ) < span class ="op "> &</ span > theme_bw() < span class ="op "> &</ span > theme(</ span >
@@ -495,7 +495,7 @@ <h1>Composing in plotnine is not like R’s patchwork</h1>
495495</ div >
496496</ div >
497497< p > But if we add < code > plot_spacer()</ code > s then it won’t line up because it seems that the space that the legend occupies is now ignored:</ p >
498- < div id ="9197a640 " class ="cell " data-execution_count ="9 ">
498+ < div id ="4478ca98 " class ="cell " data-execution_count ="9 ">
499499< div class ="code-copy-outer-scaffold "> < div class ="sourceCode cell-code " id ="cb9 "> < pre class ="sourceCode python code-with-copy "> < code class ="sourceCode python "> < span id ="cb9-1 "> < a href ="#cb9-1 " aria-hidden ="true " tabindex ="-1 "> </ a > Stack([plot_highlight_industry, p1]) < span class ="op "> &</ span > scale_x_datetime(</ span >
500500< span id ="cb9-2 "> < a href ="#cb9-2 " aria-hidden ="true " tabindex ="-1 "> </ a > expand< span class ="op "> =</ span > (< span class ="dv "> 0</ span > , < span class ="dv "> 0</ span > )</ span >
501501< span id ="cb9-3 "> < a href ="#cb9-3 " aria-hidden ="true " tabindex ="-1 "> </ a > ) < span class ="op "> &</ span > theme_bw() < span class ="op "> &</ span > theme(</ span >
0 commit comments