import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
# Generate positively correlated datasets
x1 = np.random.rand(100)
y1 = 2 * x1 + np.random.normal(0, 0.1, 100)
df1 = pd.DataFrame({'x': x1, 'y': y1})
a = sns.scatterplot(data=df1, x='x', y='y')
text = f"r = {df1.corr().loc['x', 'y']:.2f}"
plt.text(0.5, 0.5, text, fontsize=12, ha='center', va="center")
a.set_title('Positive Correlation')
a.legend()
plt.show()/tmp/ipykernel_504852/1546156619.py:17: UserWarning: No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
a.legend()



