I have the following code using the seaborn
library in python that plots a grid of histograms from data from within the seaborn
library:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns, numpy as np
from pylab import *
penguins = sns.load_dataset('penguins')
sns.displot(penguins, x='bill_length_mm', col='species', row='island', hue='island',height=3,
aspect=2,facet_kws=dict(margin_titles=True, sharex=False, sharey=False),kind='hist', palette='viridis')
plt.show()
This produces the following grid of histograms:
And so we have histograms for each species-island combination showing the frequency distribution of different penguin bill lengths, organized in a "grid" of histograms, where the columns of this grid of histograms are organized by species and the rows of this grid are organized by island. And so, I see that seaborn automatically names each column label as the "species" by the argument: col=species
. I then see seaborn labels each row as "Count" with the rows organized by island, with different representative "hues" from the argument: hue=island
.
What I am trying to do is override these default automatic labels to add my own customization. Specifically what I want to do is replace the top axes labels with just "A", "B", and "C" below a "Species" header, and on the left axis, replace each "Count" instance with the names of each island, but all of these labels in much bigger font size.
This is what I am trying to produce:
What I am trying to figure out is, how can I "override" the automatic labelling from the above seaborn arguments so that I can print my custom histogram grid labels, but done in a dynamic way, such that if there were potentially another data set with more islands and more species, the intended labelling organization would still be produced?