View source: R/SampleScatter.R
SampleScatter | R Documentation |
Given 2D points having X and Y coordinates takes a sample, such that these points are is optimally visualized if a plot function is called.
SampleScatter(X, Y, ThresholdPoints = 20,
DensityThreshold, nbins = 100,na.rm=TRUE, PlotIt = FALSE)
X |
[1:n] x coordinate |
Y |
[1:n] y coordinate |
ThresholdPoints |
how many points per grid are allowed to overlap, default 20 |
DensityThreshold |
default is internally estimated, scalar above zero and below 1, SDH threshold for density computed with |
nbins |
number of bins in grid, default 100x100 |
na.rm |
Function may not work with non finite values. If these cases should be automatically removed, set parameter TRUE |
PlotIt |
Plots the remaining points |
"Optimally"" visualized in the sense that not too much point overap visually. The lower the value for ThresholdPoints
, the smaller is the sample that is taken by the function.
SubsampleInd[1:m] indices of m points, m<n, that will be relevant for a optimal scatter plot
Michael Thrun
SmoothedDensitiesXY
if(requireNamespace("DataVisualizations")){
data("ITS",package = "DataVisualizations")
data("MTY",package = "DataVisualizations")
sample_ind=SampleScatter(ITS,MTY,PlotIt=TRUE)
}else{
#sample random data
ITS=rnorm(10000)
MTY=rnorm(10000)
sample_ind=SampleScatter(ITS,MTY,ThresholdPoints = 5)
del_ind=setdiff(1:length(ITS),sample_ind)
plot(ITS,MTY,type="p",pch=20,col="grey",main="Grey=full data, red=overlapping data points")
points(ITS[del_ind],MTY[del_ind],type="p",pch=20,col="red")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.