I have a DataFrame (data
) with a simple integer index and 5 columns. The columns are Date
, Country
, AgeGroup
, Gender
, Stat
. (Names changed to protect the innocent.) I would like to produce a FacetGrid
where the Country
defines the row, AgeGroup
defines the column, and Gender
defines the hue. For each of those particulars, I would like to produce a time series graph. I.e. I should get an array of graphs each of which has 2 time series on it (1 male, 1 female). I can get very close with:
g = sns.FacetGrid(data, row='Country', col='AgeGroup', hue='Gender')
g.map(plt.plot, 'Stat')
However this just gives me the sample number on the x-axis rather than the dates. Is there a quick fix in this context.
More generally, I understand that the approach with FacetGrid
is to make the grid and then map
a plotting function to it. If I wanted to roll my own plotting function, what are the conventions it needs to follow? In particular, how can I write my own plotting function (to pass to map
for FacetGrid
) that accepts multiple columns worth of data from my dataset?