Using seaborn, I created two Facetgrid (seaborn.axisgrid.FacetGrid
) plots as follows:
#load dataset
import pandas as pd
iris=pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
#plotting
import matplotlib.pyplot as plt
import seaborn as sns
g1 = sns.FacetGrid(pd.melt(iris.loc[:,['sepal_length','sepal_width','species']], id_vars='species'), col='variable')
g1.map(sns.boxplot, 'species','value',order=['setosa','versicolor','virginia'])
g2 = sns.FacetGrid(iris, col="species")
g2.map(plt.scatter, "sepal_length", "sepal_width")
Two separate plots were generated:
and
I would like to have them in a single figure (and save as a single pdf file). However, I could not find any way to concatenate the plots (through python). I can always use Illustrator/Inkscape or bash commands to concatenate separate plots. However I want to avoid that and do all the steps in python alone.
I tried fig.axes.append
(fig.axes.append(g1.axes.flatten()[0])
), but the subplots ended up overlapping each other.
Question: Is it possible to concatenate two seaborn-Facegrid plots?