1

I would like to create a little label of text for each subplot in my facet grid, the text is in a dataframe (two columns: one for the R value, one for the p value that I want to print in the label). I can't figure out how to loop through the dataframe or to index it so that each subplot gets the corresponding label, i.e. subplot 1 = values from row 1 of the dataframe. This is what I have so far, any help would be appreciated!

g = sns.lmplot(data=T, y='Score', x='Value', col="MPM", row="Test")

for ax in g.axes.flat:
    ax.text(0.02, 0.02, f'R = {...}, p = {...}', horizontalalignment='left',  
            verticalalignment='bottom', size='medium', color='black', transform=ax.transAxes)
RBG
  • 69
  • 1
  • 5
  • You might want to look into `for (row_val, col_val), ax in g.axes_dict.items():`. See the examples at [sns.FacetGrid](https://seaborn.pydata.org/generated/seaborn.FacetGrid.html) – JohanC Mar 26 '22 at 16:34
  • See the **second** answer at [Seaborn lmplot with equation and R2 text](https://stackoverflow.com/a/66325227/12046409) about using `g.map()` – JohanC Mar 26 '22 at 17:23

0 Answers0