Series attribute to show empty bins as 0.
This commit is contained in:
parent
3509648553
commit
f75ae01c16
@ -42,6 +42,7 @@ const _arg_desc = KW(
|
||||
:arrow => "nothing (no arrows), Bool (if true, default arrows), Arrow object, or arg(s) that could be style or head length/widths. Defines arrowheads that should be displayed at the end of path line segments (just before a NaN and the last non-NaN point). Used in quiverplot, streamplot, or similar.",
|
||||
:normalize => "Bool or Symbol. Histogram normalization mode. Possible values are: false/:none (no normalization, default), true/:pdf (normalize to a discrete Probability Density Function, where the total area of the bins is 1), :probability (bin heights sum to 1) and :density (the area of each bin, rather than the height, is equal to the counts - useful for uneven bin sizes).",
|
||||
:weights => "AbstractVector. Used in histogram types for weighted counts.",
|
||||
:show_empty_bins => "Bool. Whether empty bins in a 2D histogram are colored as 0 (true), or transparent (the default).",
|
||||
:contours => "Bool. Add contours to the side-grids of 3D plots? Used in surface/wireframe.",
|
||||
:contour_labels => "Bool. Show labels at the contour lines?",
|
||||
:match_dimensions => "Bool. For heatmap types... should the first dimension of a matrix (rows) correspond to the first dimension of the plot (x-axis)? The default is false, which matches the behavior of Matplotlib, Plotly, and others. Note: when passing a function for z, the function should still map `(x,y) -> z`.",
|
||||
|
||||
@ -272,6 +272,7 @@ const _series_defaults = KW(
|
||||
:arrow => nothing, # allows for adding arrows to line/path... call `arrow(args...)`
|
||||
:normalize => false, # do we want a normalized histogram?
|
||||
:weights => nothing, # optional weights for histograms (1D and 2D)
|
||||
:show_empty_bins => false, # should empty bins in 2D histogram be colored as zero (otherwise they are transparent)
|
||||
:contours => false, # add contours to 3d surface and wireframe plots
|
||||
:contour_labels => false,
|
||||
:match_dimensions => false, # do rows match x (true) or y (false) for heatmap/image/spy? see issue 196
|
||||
@ -574,6 +575,7 @@ add_aliases(:xerror, :xerr, :xerrorbar)
|
||||
add_aliases(:yerror, :yerr, :yerrorbar, :err, :errorbar)
|
||||
add_aliases(:quiver, :velocity, :quiver2d, :gradient, :vectorfield)
|
||||
add_aliases(:normalize, :norm, :normed, :normalized)
|
||||
add_aliases(:show_empty_bins, :showemptybins, :showempty, :show_empty, :show_zeros, :showzeros)
|
||||
add_aliases(:aspect_ratio, :aspectratio, :axis_ratio, :axisratio, :ratio)
|
||||
add_aliases(:match_dimensions, :transpose, :transpose_z)
|
||||
add_aliases(:subplot, :sp, :subplt, :splt)
|
||||
|
||||
@ -234,7 +234,7 @@ const _base_supported_args = [
|
||||
:subplot_index,
|
||||
:discrete_values,
|
||||
:projection,
|
||||
|
||||
:show_empty_bins
|
||||
]
|
||||
|
||||
function merge_with_base_supported(v::AVec)
|
||||
|
||||
@ -129,6 +129,16 @@ PlotExample("Histogram2D",
|
||||
end)]
|
||||
),
|
||||
|
||||
PlotExample("Histogram2D (complex values)",
|
||||
"",
|
||||
[:(begin
|
||||
n = 10_000
|
||||
x = exp.(0.1randn(n) .+ randn(n).*(im))
|
||||
histogram2d(x, nbins=(20,40), show_empty_bins=true,
|
||||
normed=true, aspect_ratio=1)
|
||||
end)]
|
||||
),
|
||||
|
||||
PlotExample("Line types",
|
||||
"",
|
||||
[:(begin
|
||||
|
||||
@ -755,12 +755,14 @@ end
|
||||
edge_x, edge_y, weights = x, y, z.surf
|
||||
|
||||
float_weights = float(weights)
|
||||
if float_weights === weights
|
||||
float_weights = deepcopy(float_weights)
|
||||
end
|
||||
for (i, c) in enumerate(float_weights)
|
||||
if c == 0
|
||||
float_weights[i] = NaN
|
||||
if !plotattributes[:show_empty_bins]
|
||||
if float_weights === weights
|
||||
float_weights = deepcopy(float_weights)
|
||||
end
|
||||
for (i, c) in enumerate(float_weights)
|
||||
if c == 0
|
||||
float_weights[i] = NaN
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user