kernel-density

Unnormalized histogram plots in Seaborn are not centered on X-axis

妖精的绣舞 提交于 2021-01-07 01:33:50
问题 I am graphing the number of occurrences that a value occurs in two different datasets. One plot (plot 1) graphs perfectly, the bars are right above the numbers on the x-axis. On the second plot (plot 2), there should be two bars, one above the 1 x-axis value and the other above the 2 x-axis value, but both bars are thick and squashed between 1 and 2on the x-axis. How do I get the second graph to look like the first graph? This is the code that I used in Jupyter notebook to generate both plots

How to find Local maxima in Kernel Density Estimation?

橙三吉。 提交于 2020-12-30 08:18:05
问题 I'm trying to make a filter (to remove outlier and noise) using kernel density estimators(KDE). I applied KDE in my 3D (d=3) data points and that gives me the probability density function (PDF) f(x). Now as we know local maxima of density estimation f(x) defined the centers of the clusters of data points. So my idea is to define the appropriate f(x) which will determine those clusters. My question is how and what method will be better suited for this purpose of finding local maxima in f(x).

Seaborn KDEPlot - not enough variation in data?

别来无恙 提交于 2020-06-15 07:23:05
问题 I have a data frame containing ~900 rows; I'm trying to plot KDEplots for some of the columns. In some columns, a majority of the values are the same, minimum value. When I include too many of the minimum values, the KDEPlot abruptly stops showing the minimums. For example, the following includes 600 values, of which 450 are the minimum, and the plot looks fine: y = df.sort_values(by='col1', ascending=False)['col1'].values[:600] sb.kdeplot(y) But including 451 of the minimum values gives a

Edge effects Density 2D plot with KDE

☆樱花仙子☆ 提交于 2020-05-26 09:33:31
问题 I'm plotting a simple 2D density map obtained with scipy.stats.gaussian_kde. There is always a plotting artifact towards the edges where the density appears to be lower: I've tried every interpolation method in imshow() and none seems to be able to get rid of it. Is there a proper way to handle this? import numpy as np from scipy import stats import matplotlib.pyplot as plt x_data = np.random.uniform(1., 2000., 1000) y_data = np.random.uniform(1., 2000., 1000) xmin, xmax = np.min(x_data), np

Height values for each point in a plot

吃可爱长大的小学妹 提交于 2020-04-13 07:22:32
问题 I have a data of protein-protein interactions in a data frame entitled: s1m. Each DB and AD pair make an interaction and I can plot it as well: > head(s1m) DB_num AD_num [1,] 2 8153 [2,] 7 3553 [3,] 8 4812 [4,] 13 7838 [5,] 24 3315 [6,] 24 6012 Plot of the data looks like: I then used code I found on this site to plot filled contour lines: ## compute 2D kernel density, see MASS book, pp. 130-131 require(MASS) z <- kde2d(s1m[,1], s1m[,2], n=50) plot(s1m, xlab="X label", ylab="Y label", pch=19,

choosing bandwidth&linspace for kernel density estimation. (why my bandwidth doesn't work?)

久未见 提交于 2020-02-25 05:03:13
问题 I have followed this link for the application of kernel density estimation. My aim is creating two different groups/clusters or more for an array group. The below code works for every members of array group except this array: X = np.array([[77788], [77793],[77798], [77803], [92886], [92891], [92896], [92901]]) So my expectation is seeing two different clusters such as: first_group = ([[77788], [77793],[77798], [77803]]) second_group = ([[92886], [92891], [92896], [92901]]) I have a dynamic