Histogram in Julia

I did:

edges, counts  = imhist(imgG,8);
plot(edges, counts, label="line") ;
scatter!(edges, counts, label="points");
xlabel!("Intensities");
ylabel!("Counts");
title!("Hist");

imgG is a grayscale image.

I am getting an error:

BoundsError: attempt to access 6-element Array{Float64,1} at index [1:7]

I am using plotlyjs.

Any help plz? Thanks!

Please provide a minimum working example.

Ordinarily one might say RTFM, but I have some sympathy here: Images.imhist is pointlessly painful to use. It gives the interior portion of an array
[-Inf, edges[1],...,edges[end],Inf]

So try using this instead of edges in your plot calls:

plotvals = midpoints([minimum(imgG[:]),edges...,maximum(imgG[:])])