density

D = density(x; first::Bool=true, nbins::Integer=200, bins::Vector{<:Real}=Vector{Real}(),
            bandwidth=nothing, kernel::StrSymb="normal", printbw::Bool=false,
            extend=0, plot::Bool=true, kwargs...)

Calculate the kernel density ‘d’ of a dataset X at query points determined by nbins or bins.

Returns

  • nothing or a GMTps and plots the density curve directly if plot=true (the fedault) and shows it is show=true.
  • D: A GMTdataset with two columns: first the query points and second the density values.

The version

G = density(data, x,y; weights=nothing, bandwidth=nothing, showbw=false)

Computes the smoothed kernel probability density estimate of a two-column matrix data. The estimate is based on a normal kernel function, and is evaluated at the points defined by the vectors x and y. The showbw option is used to print the bandwidth used. It returns a GMTgrid of the same size as x and y.

Example

X = [0.5*rand(20,1) 5 .+ 2.5*rand(20,1); .75 .+ 0.25*rand(10,1) 8.75 .+ 1.25*rand(10,1)];
G = GMT.density(X, -0.25:.05:1.25, 0:.1:15);
viz(G, figsize=(12,12), view=(225,30))
UndefVarError: `GMT` not defined

Stacktrace:
 [1] top-level scope
   @ In[2]:1

See other examples at

and here ?@sec-examples-of-density-plots

Source Code

This function has multiple methods:

See Also