Preview

These recipe tutorials are intended for individuals who already have a working knowledge of the grammar of plotnine, but would like to build a richer vocabulary for themselves via the stat extension mechanism.

Our recipes take the form:

Step 0. Get the job done with ‘base’ plotnine. It’s a good idea to clarify what needs to happen without getting into the extension architecture

Step 1. Define compute. Test. Wrap the necessary computation into a function that your target geom_*() function will perform. We focus on ‘compute_group’ computation only in this tutorial.

Step 2. Define stat. Test. Subclassing plotnine’s stat class lets your extension work together with base plotnine functions. You’ll use the computation function from step 1 to help define a new stat.

Step 3. Define user-facing functions. Test. You’re ready to write your function for use in plotnine pipelines, using the stat you wrote in Step 2.

Go to Recipe #1.