6565< script src ="site_libs/quarto-search/fuse.min.js "> </ script >
6666< script src ="site_libs/quarto-search/quarto-search.js "> </ script >
6767< meta name ="quarto:offset " content ="./ ">
68+ < link href ="./logo.svg " rel ="icon " type ="image/svg+xml ">
6869< script src ="site_libs/quarto-html/quarto.js " type ="module "> </ script >
6970< script src ="site_libs/quarto-html/tabsets/tabsets.js " type ="module "> </ script >
7071< script src ="site_libs/quarto-html/axe/axe-check.js " type ="module "> </ script >
@@ -239,12 +240,12 @@ <h2 id="toc-title">On this page</h2>
239240< h1 class ="hidden unlisted unnumbered "> Setup</ h1 >
240241< section id ="parameters " class ="level2 ">
241242< h2 class ="anchored " data-anchor-id ="parameters "> Parameters</ h2 >
242- < div id ="292212f9 " class ="cell " data-execution_count ="1 ">
243+ < div id ="7ab78c1f " class ="cell " data-execution_count ="1 ">
243244< 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 >
244245< 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 >
245246< 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 >
246247</ div >
247- < div id ="5b54b959 " class ="cell " data-tags ="["parameters"] " data-execution_count ="2 ">
248+ < div id ="76e8dd03 " class ="cell " data-tags ="["parameters"] " data-execution_count ="2 ">
248249< 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 >
249250< 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 >
250251< 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 +263,7 @@ <h2 class="anchored" data-anchor-id="parameters">Parameters</h2>
262263</ section >
263264< section id ="libraries " class ="level2 ">
264265< h2 class ="anchored " data-anchor-id ="libraries "> Libraries</ h2 >
265- < div id ="88692765 " class ="cell " data-execution_count ="3 ">
266+ < div id ="2d629906 " class ="cell " data-execution_count ="3 ">
266267< 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 >
267268< span id ="cb4-2 "> < a href ="#cb4-2 " aria-hidden ="true " tabindex ="-1 "> </ a > read_labourcan,</ span >
268269< span id ="cb4-3 "> < a href ="#cb4-3 " aria-hidden ="true " tabindex ="-1 "> </ a > calculate_centered_rank,</ span >
@@ -281,7 +282,7 @@ <h2 class="anchored" data-anchor-id="libraries">Libraries</h2>
281282< 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 >
282283< 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 >
283284</ div >
284- < div id ="7109d149 " class ="cell " data-execution_count ="4 ">
285+ < div id ="72c8b5af " class ="cell " data-execution_count ="4 ">
285286< 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 >
286287< span id ="cb5-2 "> < a href ="#cb5-2 " aria-hidden ="true " tabindex ="-1 "> </ a > </ span >
287288< span id ="cb5-3 "> < a href ="#cb5-3 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="co "> # Remove Aggregated Rows</ span > </ span >
@@ -336,7 +337,7 @@ <h2 class="anchored" data-anchor-id="libraries">Libraries</h2>
336337< 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 >
337338</ div >
338339< p > Stats</ p >
339- < div id ="6af1b526 " class ="cell " data-execution_count ="5 ">
340+ < div id ="0695f077 " class ="cell " data-execution_count ="5 ">
340341< 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 >
341342< span id ="cb6-2 "> < a href ="#cb6-2 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="co "> # Define offsets</ span > </ span >
342343< span id ="cb6-3 "> < a href ="#cb6-3 " aria-hidden ="true " tabindex ="-1 "> </ a > offsets < span class ="op "> =</ span > {</ span >
@@ -392,7 +393,7 @@ <h2 class="anchored" data-anchor-id="libraries">Libraries</h2>
392393< h1 > Horizontal legend with horizontal legend text</ h1 >
393394< 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 >
394395< 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 ="fa0d3674 " class ="cell " data-execution_count ="6 ">
396+ < div id ="5ebc84d5 " class ="cell " data-execution_count ="6 ">
396397< div class ="cell-output cell-output-display ">
397398< div >
398399< figure class ="figure ">
@@ -407,7 +408,7 @@ <h1>Composing in plotnine is not like R’s patchwork</h1>
407408< 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 >
408409< 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 >
409410< 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 ="b748a0b2 " class ="cell " data-execution_count ="7 ">
411+ < div id ="62b04a91 " class ="cell " data-execution_count ="7 ">
411412< 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 >
412413< 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 >
413414< span id ="annotated-cell-6-3 "> < a href ="#annotated-cell-6-3 " aria-hidden ="true " tabindex ="-1 "> </ a > </ span >
@@ -480,7 +481,7 @@ <h1>Composing in plotnine is not like R’s patchwork</h1>
480481</ div >
481482< p > The x axes don’t automatically line up</ p >
482483< p > This can be fixed by ensuring < code > expand</ code > and the < code > limits</ code > is the same:</ p >
483- < div id ="677e1d8e " class ="cell " data-execution_count ="8 ">
484+ < div id ="0fb3c5ff " class ="cell " data-execution_count ="8 ">
484485< 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 >
485486< 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 >
486487< 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 +496,7 @@ <h1>Composing in plotnine is not like R’s patchwork</h1>
495496</ div >
496497</ div >
497498< 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 ="ff399838 " class ="cell " data-execution_count ="9 ">
499+ < div id ="508ee3ec " class ="cell " data-execution_count ="9 ">
499500< 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 >
500501< 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 >
501502< 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