-1

As the title states I want to impose a circle over my scatter plot

let's say I have a df like this

+--------+---------+------+
| X_GRID | Y_GRID  | GRP  |
+--------+---------+------+
|      1 |       0 | HOT  |
|      2 |      -1 | COLD |
|      1 |       2 | COLD |
|      2 |       1 | HOT  |
+--------+---------+------+

and I use it to create a scatter plot like so

ax = sns.scatterplot(data=df, hue='GRP', x='X_GRID', y='Y_GRID')
ax.set(xlim=(-4, 4))
ax.set(ylim=(-4, 4))

How would I go about imposing a red circle (or any color) around my scatter plot of say radius = 2 at around (0,0)?

mike_gundy123
  • 469
  • 5
  • 18

1 Answers1

3

Refered from here

import pandas as pd
import seaborn as sns
df = pd.DataFrame()
df['X_GRID'] = [1,2,1,2]
df['Y_GRID'] = [0,-1,2,1]
df['GRP'] = ['HOT','COLD','COLD','HOT']
circle1 = plt.Circle(xy=(0, 0), radius=2, color='red', fill=False)
ax = sns.scatterplot(data=df, hue='GRP', x='X_GRID', y='Y_GRID')
ax.add_patch(circle1)
ax.set(xlim=(-4, 4))
ax.set(ylim=(-4, 4));
Zeel B Patel
  • 691
  • 5
  • 16