Reputation: 1922
I am using Seaborn's jointplot to generate some scatterplots.
Here is a sample of what I have done, and its outcome:
from scipy import stats
x = np.arange(100) + np.random.randn(100)*20
y = np.arange(100) + np.random.randn(100)*20
g = sb.JointGrid(x, y, ratio=100)
g.plot_joint(sb.regplot)
g.annotate(stats.spearmanr)
g.ax_marg_x.set_axis_off()
g.ax_marg_y.set_axis_off()
plt.xlabel('X', fontsize=18)
plt.ylabel('Y', fontsize=18)
plt.tick_params(axis="both", labelsize=18)
plt.legend(fontsize=20)
Here is the resulting plot.
How can I change the size of the text displayed in the plot (text for the correlation coefficient and the p-value)?
Upvotes: 4
Views: 4846
Reputation: 119
This example from Seaborn page explains it well.
g = sns.JointGrid(x="total_bill", y="tip", data=tips)
g = g.plot_joint(plt.scatter,
color="g", s=40, edgecolor="white")
g = g.plot_marginals(sns.distplot, kde=False, color="g")
rsquare = lambda a, b: stats.pearsonr(a, b)[0] ** 2
g = g.annotate(rsquare, template="{stat}: {val:.2f}",
stat="$R^2$", loc="upper left", fontsize=12)
Hence you can just try this
g = sns.jointplot(x="", y="", data=df,kind='reg');
g = g.annotate(stats.pearsonr, fontsize=18)
Upvotes: 3