Merge pull request #2062 from yha/show-empty-bins
Series attribute to show empty bins as 0.
This commit is contained in:
commit
76c7d9dc89
@ -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.",
|
: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).",
|
: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.",
|
: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.",
|
:contours => "Bool. Add contours to the side-grids of 3D plots? Used in surface/wireframe.",
|
||||||
:contour_labels => "Bool. Show labels at the contour lines?",
|
: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`.",
|
: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...)`
|
:arrow => nothing, # allows for adding arrows to line/path... call `arrow(args...)`
|
||||||
:normalize => false, # do we want a normalized histogram?
|
:normalize => false, # do we want a normalized histogram?
|
||||||
:weights => nothing, # optional weights for histograms (1D and 2D)
|
: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
|
:contours => false, # add contours to 3d surface and wireframe plots
|
||||||
:contour_labels => false,
|
:contour_labels => false,
|
||||||
:match_dimensions => false, # do rows match x (true) or y (false) for heatmap/image/spy? see issue 196
|
:match_dimensions => false, # do rows match x (true) or y (false) for heatmap/image/spy? see issue 196
|
||||||
@ -581,6 +582,7 @@ add_aliases(:xerror, :xerr, :xerrorbar)
|
|||||||
add_aliases(:yerror, :yerr, :yerrorbar, :err, :errorbar)
|
add_aliases(:yerror, :yerr, :yerrorbar, :err, :errorbar)
|
||||||
add_aliases(:quiver, :velocity, :quiver2d, :gradient, :vectorfield)
|
add_aliases(:quiver, :velocity, :quiver2d, :gradient, :vectorfield)
|
||||||
add_aliases(:normalize, :norm, :normed, :normalized)
|
add_aliases(:normalize, :norm, :normed, :normalized)
|
||||||
|
add_aliases(:show_empty_bins, :showemptybins, :showempty, :show_empty)
|
||||||
add_aliases(:aspect_ratio, :aspectratio, :axis_ratio, :axisratio, :ratio)
|
add_aliases(:aspect_ratio, :aspectratio, :axis_ratio, :axisratio, :ratio)
|
||||||
add_aliases(:match_dimensions, :transpose, :transpose_z)
|
add_aliases(:match_dimensions, :transpose, :transpose_z)
|
||||||
add_aliases(:subplot, :sp, :subplt, :splt)
|
add_aliases(:subplot, :sp, :subplt, :splt)
|
||||||
|
|||||||
@ -229,7 +229,7 @@ const _base_supported_args = [
|
|||||||
:subplot_index,
|
:subplot_index,
|
||||||
:discrete_values,
|
:discrete_values,
|
||||||
:projection,
|
:projection,
|
||||||
|
:show_empty_bins
|
||||||
]
|
]
|
||||||
|
|
||||||
function merge_with_base_supported(v::AVec)
|
function merge_with_base_supported(v::AVec)
|
||||||
|
|||||||
@ -467,8 +467,17 @@ PlotExample("Ribbons",
|
|||||||
plot(0:10; ribbon = sqrt),
|
plot(0:10; ribbon = sqrt),
|
||||||
plot(0:10; ribbon = 1),
|
plot(0:10; ribbon = 1),
|
||||||
)
|
)
|
||||||
end)
|
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)]
|
||||||
),
|
),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@ -746,12 +746,14 @@ end
|
|||||||
edge_x, edge_y, weights = x, y, z.surf
|
edge_x, edge_y, weights = x, y, z.surf
|
||||||
|
|
||||||
float_weights = float(weights)
|
float_weights = float(weights)
|
||||||
if float_weights === weights
|
if !plotattributes[:show_empty_bins]
|
||||||
float_weights = deepcopy(float_weights)
|
if float_weights === weights
|
||||||
end
|
float_weights = deepcopy(float_weights)
|
||||||
for (i, c) in enumerate(float_weights)
|
end
|
||||||
if c == 0
|
for (i, c) in enumerate(float_weights)
|
||||||
float_weights[i] = NaN
|
if c == 0
|
||||||
|
float_weights[i] = NaN
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user