Plotting subspaces

Plotting subspaces#


On this page, you will see how to

  • use the subspace key to select only certain parts of the parameter space for plotting

  • use col_wrap: auto when plotting facet_grid panels to automatically square a plot with many columns and few rows.

For large parameter sweeps across many dimensions, you may often wish to only select a subspace of the whole parameter space for plotting. This is easily achieved using the subspace key. Subspace selection will also improve performance speeds, since less data is being loaded into memory.

Consider the facet grid example we considered in a previous section. Here, we performed a parameter sweep across three dimensions (seed, transmission rate, immunity rate) and plotted the resulting curves of the susceptible, infected, and recovered populations:

A facet grid example

If we want to restrict ourselves to the subspace of transmission rate = 0.2 and immunity rate < 0.3, we can do the following:


  # Same as before
    - .creator.multiverse
    - .plot.facet_grid.errorbands

        path: densities
          - .sel: [!dag_prev , { kind: [infected] }]

    # Add the following entry:
      transmission rate: [0.2]
      immunity rate: [0, 0.1, 0.2]

    - # same as before ...

  x: time
  y: infected density
  yerr: yerr
  col: immunity rate
  hue: kind

Note that we are no longer assigning the row key, as there is only a single row to plot! The subspace selection led to a dimensionality reduction.

The output then looks like this:

A facet grid example with subspace selection


Subspace selection happens via the ParamSpace method activate_subspace(), which also offers some other syntax options.


If you have lots of columns and few rows, use col_wrap: auto to create a more square plot.