I'm working on a project that have X and Y values and I try to explore the area where no data must be exist. As can be seen from the Figures, most of the data gathered in the sides of the red line and there are some data inside the red line. I just want to remove those outliers but couldn't achieve it. I try to use Reverse KNN algorithms or distance calculations but they didn't work in my data or I couldn't make it. Is there any possible solution for this?
My python code for the scatter plot is below.
import pyodbc
import matplotlib.pyplot as plt
from astroML.plotting import scatter_contour
import numpy as np
import pandas as pd
conn = pyodbc.connect('Driver={SQL Server};'
'Server=test;'
'Database=test;'
'Trusted_Connection=yes;')
sqlquery= "SELECT test FROM test"
SQL_Query = pd.read_sql_query (sqlquery, conn)
df = pd.DataFrame(SQL_Query, columns=['Data1', 'Data2'])
x = df['Data1']
y = df['Data2']
fig,ax = plt.subplots(1,1,figsize=(15,15))
scatter_contour(x,y, threshold=20, log_counts=True, ax=ax,
histogram2d_args=dict(bins=45),
plot_args=dict(marker='.', linestyle='none', color='black',
markersize=1),
contour_args=dict(cmap='summer',),
filled_contour=False)

