I'm plotting pandas data using a seaborn factorplot. The code is as follows:
import seaborn
import numpy as np
import pandas as pd
seaborn.set_style("white")
fg = seaborn.factorplot(x='Group', y='val', hue='Mean',
col='Sex', data=data, kind='bar', ci=68, row='Split', x_order=['Group 1', 'Group 2'],
row_order=['Poor','Good'], col_order=['Male', 'Female'], sharex=False, sharey=False,
palette='deep', legend_out=False
)
(fg.set_axis_labels("", "val")
.set_titles("{row_name} - {col_name}")
.set(ylim=(0, 300))
.despine(left=True)
)
Here is an example dataframe:
groups = ('Group 1', 'Group 2')
sexes = ('Male', 'Female')
means = ('Low', 'High')
split = ('Poor', 'Good')
index = pd.MultiIndex.from_product(
[groups, sexes, means, split],
names=['Group', 'Sex', 'Mean', 'Split']
)
values = np.random.randint(low=20, high=100, size=len(index))
data = pd.DataFrame(data={'val': values}, index=index).reset_index()
I've looked to see what aesthetic options seaborn has and there are a few that I cannot find reference to:
This creates a 2x2 grid of 4 plots. How do I adjust the spacing between each of the plots? Right now, everything is too close together
How do I individually set the font size for the seperate labels? I'd like some axis/categorical labels to be bigger than others
How do I completely remove the legend title?
With a 2x2 grid of plots, is it possible to put the 2 plots in the same row onto the same plot? i.e. connect the x axis, remove the y axis on the right plot
Is it possible to save plots to a vector based file format?