688
questions
0
votes
0
answers
25
views
ggplot2 density2d vs seaborn kde / Or shorter range in density2d
2D density plot seems to exclude some areas, I assume, because of too small number of points comparing to the 'main cloud'. Interestingly, it seems to work better in seaborn kde plot.
Below you can ...
0
votes
0
answers
24
views
I can't overlay density plots (from a spatstat hyperframe) with the respective contours
I am a cell biologist and I work with replicated point data. Therefore, I pooled the ppp's in a listof. I created density plots (with the generic plot tool) and contours, and I can plot both as lists (...
1
vote
1
answer
37
views
Why does scdensity not work with boundedRight in this code?
I'm trying to get kernal density estimates for values that are bounded [0, 1] (a proportion), and to get value for where specific quantiles occur in that density estimate. The R package scdensity has ...
0
votes
0
answers
26
views
How do I map a data to another Cumulative Distribution Function (CDF)?
I am left with a task to match two arrays(simulated and actual observations) with the help of their cumulative density function (CDF). Accoring to a literature: “At first, CDFs of both actual and ...
0
votes
0
answers
27
views
seaborn kdeplot overly smooth for bimodal data
I frequently want to make a contour plot of the density of bivariate data. Sometimes the data are bimodal, like this:
import numpy as np
x = np.concatenate([np.random.normal(size=1000, scale=.5),
...
1
vote
1
answer
79
views
KDE using simple features grid uses centroids instead of grid cell
I would like to make a KDE out of an sf object. For this, I made a grid as rectangle, but R does not take it. Instead, it is using the centroid of the polygons.
This is what I tried:
library(sf)
...
0
votes
0
answers
9
views
Need Help Understanding The Different Sizes of KDE plots
I'm new to using ridge plots and would appreciate some help understanding them. I'm trying to compare distributions of data from different advertising campaigns using kde ridge plots. In the ...
0
votes
0
answers
14
views
Instead of manually entering the bandwidth value, use automatic bandwidth selection
This is the code I create for an estimation. But I don't know what is the command to select bandwidth automatically instead of putting value manually.
import numpy as np
from scipy.stats import norm
...
0
votes
0
answers
34
views
How to Improve Kernel Density Estimation Plot Map Grid Cells for Vessel Traffic on the West Coast of Mexico in R?
I'm working on visualizing vessel traffic density for the west coast of Mexico, including Baja California and Bahia de Banderas waters, using R. I have a large dataset of vessel locations stored in a ...
0
votes
0
answers
29
views
rkdevine returns constant zero-valued simulations
I found that the rkdevine function, from the package kdevine, is returning constant zero-valued simulations when it shouldn't be the case. The function is meant to simulate from a a kdevine object, ...
0
votes
1
answer
29
views
Creating geom_violin plot with pre-created density values
I have created some weighted Kernal density estimates across different factor levels which I don't think can be incorporated within geom_violin plot estimates. I was wondering if there's a way ...
0
votes
0
answers
31
views
Kernel Density Estimation: Different Results for All Data Points vs. Within Bandwidth
I’m working on kernel density estimation (KDE) using python for road accidents data, but here I will use 1d data just for illustration. When fitting the KDE model, I’ve noticed that I get different ...
0
votes
1
answer
10
views
How to add labels on relative KDE plots?
I'm trying to plot the KDEs of two datasets using seaborn.kdeplot. I want to add separate labels for each dataset, but I'm having trouble getting the labels to work correctly. Here's my code:
import ...
0
votes
1
answer
47
views
How to Fix "TypeError: getattr(): attribute name must be string" when multiple optimizers are GridSearched for GaussianProcessRegressor?
Here is my script to predict targets on the final date of a timeseries dataset. I am trying to incorporate a GaussianProcessRegressor model to find the best hyperparameters using GridSearchCV: (Note ...
0
votes
1
answer
60
views
How to Overlay Density Plot on a Map of Alaska using ggplot2 and sf in R?
I'm trying to plot a density map of some randomly generated points in Alaska using ggplot2 and sf. I want to overlay the density on a map of the USA including Alaska. However, I am unable to make ...
1
vote
1
answer
90
views
adehabitatHR KUD loop not overlaying mapping correctly in R
I have some code which calculates KUD at 95% from fish position data, restricted by the bounds of a shapefile, and then plots this, and overlays the shapefile on top.
########## BOUND KUD TO SHAPEFILE ...
0
votes
1
answer
38
views
Converting list object (home range) to an object I can plot?
I have an example dataset (named "data") with coordinates as shown below (projected in CRS 5321):
longitude latitude
430547.6 7208993
404139.3 7212760
411915.5 7232663
...
2
votes
2
answers
120
views
Intensity outliers in 2D plot (max or min local peaks with high intensity)
I wonder what kind of method better to use to see outliers on z value of 2D plot. For example, I have measurements of x and y values both in range of 1 to 16 with step of 1. Next I calculate how many ...
1
vote
0
answers
42
views
KDE for a logarithmic data in plotly
I'm trying to use plotly violin plot for a logarithmic data set with positive values only.
when I use the regular violin aka:
fig= go.Figure()
fig.add_trace(go.Violin(x=last_value, line_color=color, ...
0
votes
0
answers
17
views
How to make get uniform scales across heat maps?
I am trying to illustrate the transformation of a data set in R. The goal is to show that an applied formula has compacted the distribution of data points and increased the density, so I want to show ...
0
votes
0
answers
30
views
Compute the right normalization when using a custom metric in scikit-learn KDE
I am interested in computing the probability distribution of some unit-vectors on the surface of the unit-sphere.
Those unit vectors come from the diagonalization of an inertia tensor, so the ...
1
vote
0
answers
29
views
comma in a Kernel equation
I have difficulties understanding the part h,1 in the definition below. What is this ,1 following the h? The code is C++.
double Temp = Kernel((X(n) - X(m)) / h,1) / h;
The mathematical form of the ...
0
votes
0
answers
43
views
Shapefiles not showing up in assigned directory in R - says it exists but can't find it
I created kde polygons in R and set the directory for output and when I run the code it works and says it exists but the shapefiles are not showing up in my folder.
Here is my code:
`Ei121130 <- ...
0
votes
1
answer
246
views
Getting the plot points for a kernel density estimate in seaborn
I am using this code
kde = sns.kdeplot(x = data, fill = True, color = "black", alpha = 0.1)
to get the kde for my data, and it works well. I am now trying to get all the x,y - point used to ...
0
votes
1
answer
35
views
Second-order statistics estimator functions in the spatial point process
I'm running into a problem with edge corrector position perception.
I would like to know when the edge corrector is placed in the numerator and when it is placed in the denominator, for example when ...
0
votes
0
answers
39
views
Python- Scipy: if I have a 2D KDE from a distribution of data, can I then feed it a 1D array of "x" vals to get corresponding "y" vals?
I have a simple 2D kernel density estimation created from x and y values, using scipy's gaussian_kde. It looks similar to the example in the gaussian_kde documentation. I have new x values (a very ...
0
votes
0
answers
102
views
Add weights to density function
I want to create a chart where predicted values are on the X axis and actual values are on the Y axis, with a scatter plot of points that also has a density plot weighted by volume. The observations ...
0
votes
0
answers
36
views
Adding Boundaries to Scipy.Stats KDE Plots
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, ...
0
votes
1
answer
132
views
How to use Python package "fastkde" to predict density at each given data point?
I am trying to use the package fastkde to estimate the density from a sample. The authors give an example
""" Demonstrate the first README example. """
import numpy as np
...
1
vote
1
answer
80
views
Gnuplot: Meaning of the second column of smooth kdensity
I am new to gnuplot. I am also new to the Kernel Density Resampling using a Gaussian supported by gnuplot using “smooth kdensity”. I played with the gnuplot demo script provided below. I am trying to ...
0
votes
1
answer
151
views
Finding the total probability under a shape in a bivariate KDE plot
I have a set of points stored as (x,y) values. My goal is the map these onto a coordinate plane and create a continuous PDF distribution.
I would like to apply polygons to the figure and get the total ...
1
vote
1
answer
63
views
Difficulty in Visualizing Spatial Density with ggplot2 and sf Package
I'm currently working on visualizing the spatial density. However, I'm facing an issue where the density plot doesn't adequately represent areas with few sampled points, particularly in regions like ...
0
votes
0
answers
37
views
Why I'm getting different outputs for the following lines of code. (KDEplot visualisation) [duplicate]
1.
Tot=sns.kdeplot(data=new_df_dummies, x=new_df_dummies.TotalCharges[new_df_dummies["Churn"]== 1], fill = True, color = 'blue')
Tot=sns.kdeplot(data=new_df_dummies, x=new_df_dummies....
0
votes
2
answers
85
views
1D kernel estimation to compare PDF ratios: how to set tails?
Trying to create 1D kernels from data observations (weekly time points). I have been using the density() function from the stats R package. I am doing this so I can take the ratio of a treatment's pdf ...
0
votes
1
answer
143
views
seaborn kdeplot: make ymax equals density max for different hues
I plotted:
with this code example:
# plot
plt.close()
g = sns.JointGrid(x="alntmscore", y="hit_count", data=foldseek_df_groupby)
# scatter plot
sns.scatterplot(x = 'alntmscore', ...
4
votes
1
answer
520
views
Plotting weighted histograms with weighted KDE (kernel density estimate)
I want to plot two distributions of data as weighted histograms with weighted kernel density estimate (KDE) plots, side by side.
The data (length of DNA fragments, split by categorical variable ...
3
votes
1
answer
145
views
Distribution Plot with Gradient Fill in Python
I'm trying to create a density plot with a gradient fill in python like this:
I've attempted to do so using this code:
plt.figure(figsize=(6, 1))
sns.kdeplot(data=df, x='Overall Rating', fill=True, ...
0
votes
1
answer
35
views
Index out of range with geoplot
I am trying to create a KDE plot to show the geographic density of each crime category. The dataset is the Philadelphia Crime Incidents and the Philadelphia Police District Boundaries.
import ...
1
vote
0
answers
135
views
How do I generate the correct volume contour from a raster using sf, spatialEco, and terra?
I am interested in using R packages spatialEco and terra to generate some kernel density estimates with data of varying weights so that I can export contour shapefiles for mapping. I'm currently ...
0
votes
1
answer
66
views
In R, how do I map a boundary corrected KDE generated using evmix::dbckdem() to the values of the input data or uncorrected KDE?
Introduction
I am trying to generate a boundary corrected kernel density estimate of a set of values which has many zeroes but which cannot go below zero (percent cover of the land surface in trees - ...
0
votes
0
answers
29
views
Stuck with different no. of rows for Calculating kernel density UDOI in R. How to proceed?
I see a couple of unanswered similar questions for the same topic and the best one so far has been this one but I cannot proceed with my UDOI for kernel densities after using that script due to "...
1
vote
1
answer
47
views
Shading area under the curve (KDE) with 2 subplots
guys!
Any ideas how to shade area under the curve with 2 subplots?
fig, axs = plt.subplots(1, 2, figsize=(11, 4.5))
N = 500
X = np.concatenate((np.random.normal(0, 1, int(0.3 * N)),
...
3
votes
2
answers
159
views
How do I divide one kernel density estimate by another?
I am trying to divide one KDE by another KDE to produce a continuous line for which the Y value at any point X is equal to the ratio of the values of the two initial KDEs at that point X.
Below is a ...
0
votes
0
answers
39
views
Suitable "h" parameter for the Kernel UD() function in R other than "href" to encompass all spatial points in the data
Sample image of data used in this script#
Here is my R-script that results in the attached output for 50 and 95% occupancy contours.
library(sp)
library(adehabitatHR)
library(raster)
library(...
0
votes
1
answer
69
views
Why does stat_density2d() not cover all points?
I am trying to represent distribution and density of a point layer I have. I am using ggplot and stand_density2d():
p1 <- ggplot()+
stat_density2d(data=tempSSI, aes(x=longitude, y=latitude, fill=...
0
votes
0
answers
47
views
why does Kernel Density Estimator need a fitting step?
I am using Kernel Density Estimator (KDE) to do a grouping of one-dimension array of numbers. All the tutorials of Scikit's KernelDensity module does this in two steps:
1: Do a fitting on a training ...
0
votes
1
answer
178
views
Plotting a PDF of an angular distribution in Python
I am trying to plot the PDF of some data I have on the angular orientation of a particles in python, using sns. The data cover the -180,180 degree range and I have problems with the fitting of the ...
0
votes
0
answers
70
views
R - Overlay points layer to a 3D density plot
I have a 3D density plot generated from x;y coordinates with the following code:
library(MASS)
den3d <- kde2d(data_loc$X, data_loc$Y)
persp(den3d, box=FALSE)
library(plotly)
gg<-plot_ly(x=den3d$...
0
votes
0
answers
129
views
Can Kernel Density Estimation be used to smooth 3D data?
I'm aware that KDE can be used to estimate the density of points in any number of dimensions. For example, if I use the sklearn implementation in python, I can simply feed in 3D data, fit the KDE ...
0
votes
0
answers
91
views
Extracting data points within the hexbins and the contour line
I use the following code to create hexbins and a kde contour line. It colours each hexbin with the average 'Score' values of data points.
import pandas as pd
import seaborn as sns
import matplotlib....