Does that help Looking for function to build histogram, something like: , You can use something like this: code :
function partition(data, intervals)
ranges = intervals[1:end1] .=> intervals[2:end]
bins = [similar(data, 0) for _ in 1:length(ranges)]
for x in data
for (i, (a, b)) in pairs(ranges)
if a <= x < b
push!(bins[i], x)
break
end
end
end
return bins
end
julia> partition([1.1, 1.2, 2.1, 2.1], 1:1:3)
2element Array{Array{Any,1},1}:
[1.1, 1.2]
[2.1, 2.1]
Share :

Getting a 2D histogram of a grayscale image in Julia
By : user2898840
Date : March 29 2020, 07:55 AM
seems to work fine hist also accepts a vector (or range) as an optional argument that specifies the edge boundaries, so code :
hist(img_gld_gs, 0:256)

Histogram calculation in julialang
By : sunflowerdeath
Date : March 29 2020, 07:55 AM
should help you out As the person who wrote the underlying function: the aim is to get bin widths that are "nice" in terms of a base10 counting system (i.e. 10k, 2×10k, 5×10k). If you want more control you can also specify the exact bin edges.

Histogram with log y axis in Julia Plots.jl
By : findLyon
Date : March 29 2020, 07:55 AM
seems to work fine The problem is that you have an axis range that goes to zero, which is Inf in log space. There are a few ways to fix this, the easiest is probably to force a lower bound on the axis: code :
using Plots; gr()
histogram(randn(1000), yaxis = (:log10, (1,Inf)))

Return the frequency in a bin of a 2D histogram in Julia
By : Sick N Sane
Date : March 29 2020, 07:55 AM
will help you I'm not 100% sure whether this is what StatsPlots is doing, but one approach could be to use StatsBase's histogram which works for N dimensions: code :
using StatsBase, StatsPlots, Distributions
# Example data
data = (randn(10_000), randn(10_000))
# Plot StatsPlots 2D histogram
histogram2d(data)
# Fit a histogram with StatsBase
h = fit(Histogram, data)
x = searchsortedfirst(h.edges[1], 0.1) # returns 10
y = searchsortedfirst(h.edges[2], 0.1) # returns 11
h.weights[x, y] # returns 243
# Or as a function
function get_freq(h, xval, yval)
x = searchsortedfirst(h.edges[1], xval)
y = searchsortedfirst(h.edges[2], yval)
h.weights[x, y]
end
get_freq(h, 1.4, 0.6) # returns 32

Doing a histogram from two sets of values (Julia 0.6.4)
By : Larry
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You can use PyPlot for this (please not that it should be installed first) code :
using PyPlot
PyPlot.plt[:hist]([x,y],bins=8);
p = PyPlot.plt[:bar](x,y,width=25);
PyPlot.plt[:cla]() #remember to clear the plot :)
PyPlot.plt[:bar](1:length(y),y);
PyPlot.plt[:xticks](1:length(y),x);

