plotnine.facets.facet_grid¶

class plotnine.facets.facet_grid(facets, margins=False, scales='fixed', space='fixed', shrink=True, labeller='label_value', as_table=True, drop=True)[source]

Wrap 1D Panels onto 2D surface

Parameters: facets : A formula with the rows (of the tabular display) on the LHS and the columns (of the tabular display) on the RHS; the dot in the formula is used to indicate there should be no faceting on this dimension (either row or column). If a tuple/list is used, it must of size two, the elements of which must be strings or lists. If string formula is not processed as you may expect, use tuple/list. For example, the follow two specifications are equivalent: 'func(var4) ~ func(var1+var3) + func(var2)' ['func(var4)', ('func(var1+var3)', 'func(var2)')]  There may be cases where you cannot use a use a pure string formula, e.g.: ['var4', ('var1+var3', 'var2')]  scales : str in ['fixed', 'free', 'free_x', 'free_y'] Whether x or y scales should be allowed (free) to vary according to the data along rows or columns. Default is 'fixed', the same scales for all the panels. space : str in ['fixed', 'free', 'free_x', 'free_y'] Whether the x or y sides of the panels should have the size. It also depends to the scales parameter. Default is 'fixed'. This setting is not yet supported. shrink : bool Whether to shrink the scales to the output of the statistics instead of the raw data. Default is True. labeller : str | function How to label the facets. If it is a str, it should be one of 'label_value' 'label_both' or 'label_context'. Default is 'label_value' as_table : bool If True, the facets are laid out like a table with the highest values at the bottom-right. If False the facets are laid out like a plot with the highest value a the top-right. Default it True. drop : bool If True, all factor levels not used in the data will automatically be dropped. If False, all factor levels will be shown, regardless of whether or not they appear in the data. Default is True.