How to add an axis to pairplot for another plot in the same figure

515 views Asked by At

I want to add another plot next to pairplot result in the same figure.

For example, this code:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.datasets import load_iris


iris = load_iris()
data = pd.DataFrame(data = np.c_[iris['data'], iris['target']], columns = iris['feature_names'] + ['target'])

sns.pairplot(data)
plt.show()
plt.plot(data['sepal length (cm)'].to_numpy())
plt.show()

I want to somehow have both the pairplot and the lineplot (plt.plot(data['sepal length (cm)'].to_numpy())) to be on the same figure. Is there a way to do so?

Like getting the figure of pairplot, extend it or something?

Update

I am not after adding a plot onto one of the pairplot axis. I want to add additional axis in the figure.

Mentally, think like:

f, ax = plt.subplots(1, 2)

ax[0] = pairplot...
ax[1] = something else...

But since pairplot returns a figure element can we add to it an axis? Change its size to be able to add more axis?

0

There are 0 answers