Adding Boundaries to Scipy.Stats KDE Plots

25 views Asked by At

I am plotting (x,y) data on a coordinate plane using a gaussian kde from the scipy stats library. While I want the kde plot to be able to extrapolate and assign a probability to areas within the map, I would also like to prevent it from assigning probability to area outside of the data extrema.

For example, I know with certainty that no point will occur at a negative x coordinate and my data confirms this; however, the kde is still assigning probability to points where x < 0.

Seaborns kdeplot has a method called cut/clip that performs a similar function, but I am unable to use seaborn's plots as they don't have other features that I require for my project.

Is anyone aware of any ways to perform this action?

The code to create the graph is located below, although it is not especially interesting.

kd_estimator = gaussian_kde(df_heatmap.T, weights=weights_df['weight'])
0

There are 0 answers