pythonggplot2gridextracowplotplotnine

is there gridExtra/cowplot type package in Python to use with Plotnine to align subplots (i.e. marginal distributions)


This is related to the following posts on aligning subplots in ggplot2 in R:

Scatterplot with marginal histograms in ggplot2

How to plot Scatters with marginal density plots use Python?

Perfectly align several plots

There are many more links on StackOverflow on this topic.

Anyhow, I haven't been able to find any documentation on how to do this with Plotnine (ggplot2 implementation) in Python.

Can this be done at all in Python? If not has there not been any demand for a solution to this problem?

Thank you for your guidance.

UPDATE:

I found this link MEP for a matplotlib geometry manager #1109 which seems to indicate that the functionality is now present in matplotlib to do this. The question is has plotnine been extended to do this?


Solution

  • So I dont know enough about plotnine to say whether it can do this but it is VERY easy in seaborn: https://seaborn.pydata.org/generated/seaborn.jointplot.html

    >>> import numpy as np, pandas as pd; np.random.seed(0)
    >>> import seaborn as sns; sns.set(style="white", color_codes=True)
    >>> tips = sns.load_dataset("tips")
    >>> g = sns.jointplot(x="total_bill", y="tip", data=tips)