Change default for bins to :auto (meaning 30 bins)
This commit is contained in:
parent
96f3baca41
commit
7843821109
@ -21,7 +21,7 @@ const _arg_desc = KW(
|
|||||||
:markerstrokewidth => "Number. Width of the marker stroke (border. in pixels)",
|
:markerstrokewidth => "Number. Width of the marker stroke (border. in pixels)",
|
||||||
:markerstrokecolor => "Color Type. Color of the marker stroke (border). `:match` will take the value from `:foreground_color_subplot`.",
|
:markerstrokecolor => "Color Type. Color of the marker stroke (border). `:match` will take the value from `:foreground_color_subplot`.",
|
||||||
:markerstrokealpha => "Number in [0,1]. The alpha/opacity override for the marker stroke (border). `nothing` (the default) means it will take the alpha value of markerstrokecolor.",
|
:markerstrokealpha => "Number in [0,1]. The alpha/opacity override for the marker stroke (border). `nothing` (the default) means it will take the alpha value of markerstrokecolor.",
|
||||||
:bins => "Integer, NTuple{2,Integer}, AbstractVector or Symbol. For histogram-types, defines the number of bins, or the edges, of the histogram, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd)",
|
:bins => "Integer, NTuple{2,Integer}, AbstractVector or Symbol. Default is :auto. For histogram-types, defines the number of bins, or the edges, of the histogram, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd)",
|
||||||
:smooth => "Bool. Add a regression line?",
|
:smooth => "Bool. Add a regression line?",
|
||||||
:group => "AbstractVector. Data is split into a separate series, one for each unique value in `group`.",
|
:group => "AbstractVector. Data is split into a separate series, one for each unique value in `group`.",
|
||||||
:x => "Various. Input data. First Dimension",
|
:x => "Various. Input data. First Dimension",
|
||||||
|
|||||||
@ -185,7 +185,7 @@ const _series_defaults = KW(
|
|||||||
:markerstrokewidth => 1,
|
:markerstrokewidth => 1,
|
||||||
:markerstrokecolor => :match,
|
:markerstrokecolor => :match,
|
||||||
:markerstrokealpha => nothing,
|
:markerstrokealpha => nothing,
|
||||||
:bins => 30, # number of bins for hists
|
:bins => :auto, # number of bins for hists
|
||||||
:smooth => false, # regression line?
|
:smooth => false, # regression line?
|
||||||
:group => nothing, # groupby vector
|
:group => nothing, # groupby vector
|
||||||
:x => nothing,
|
:x => nothing,
|
||||||
|
|||||||
@ -582,9 +582,11 @@ function _auto_binning_nbins{N}(vs::NTuple{N,AbstractVector}, dim::Integer; mode
|
|||||||
|
|
||||||
v = vs[dim]
|
v = vs[dim]
|
||||||
|
|
||||||
if mode == :sqrt # Square-root choice
|
if mode == :auto
|
||||||
|
30
|
||||||
|
elseif mode == :sqrt # Square-root choice
|
||||||
_cl(sqrt(n))
|
_cl(sqrt(n))
|
||||||
elseif mode == :sturges || mode ==:auto # Sturges' formula
|
elseif mode == :sturges # Sturges' formula
|
||||||
_cl(log2(n)) + 1
|
_cl(log2(n)) + 1
|
||||||
elseif mode == :rice # Rice Rule
|
elseif mode == :rice # Rice Rule
|
||||||
_cl(2 * n^(1/3))
|
_cl(2 * n^(1/3))
|
||||||
@ -594,7 +596,7 @@ function _auto_binning_nbins{N}(vs::NTuple{N,AbstractVector}, dim::Integer; mode
|
|||||||
_cl(_span(v) / (2 * _iqr(v) / n^(1/3)))
|
_cl(_span(v) / (2 * _iqr(v) / n^(1/3)))
|
||||||
else
|
else
|
||||||
error("Unknown auto-binning mode $mode")
|
error("Unknown auto-binning mode $mode")
|
||||||
end
|
end::Int
|
||||||
end
|
end
|
||||||
|
|
||||||
_hist_edge{N}(vs::NTuple{N,AbstractVector}, dim::Integer, binning::Integer) = StatsBase.histrange(vs[dim], binning, :left)
|
_hist_edge{N}(vs::NTuple{N,AbstractVector}, dim::Integer, binning::Integer) = StatsBase.histrange(vs[dim], binning, :left)
|
||||||
@ -611,6 +613,7 @@ _hist_norm_mode(mode::Symbol) = mode
|
|||||||
_hist_norm_mode(mode::Bool) = mode ? :pdf : :none
|
_hist_norm_mode(mode::Bool) = mode ? :pdf : :none
|
||||||
|
|
||||||
function _make_hist{N}(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing)
|
function _make_hist{N}(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing)
|
||||||
|
info("binning = $binning")
|
||||||
edges = _hist_edges(vs, binning)
|
edges = _hist_edges(vs, binning)
|
||||||
h = float( weights == nothing ?
|
h = float( weights == nothing ?
|
||||||
StatsBase.fit(StatsBase.Histogram, vs, edges, closed = :left) :
|
StatsBase.fit(StatsBase.Histogram, vs, edges, closed = :left) :
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user