Search code examples
juliabinninghistogram2d

2D Histogram with dynamical bin width


I have a problem with creating a histogram in Julia. I would like to have on a logarithmical scale that the bins have all the same size at the outcoming plot. So far I have a fixed bin width (see Code)

histogram2d((nu_m, m_ee_val),xlims = (0.01, 1), ylims = (0.0001, 1), xscale= :log10, yscale= :log10, bins=(0.01:0.001:1, 0.0001:0.0001:1))

What do I have to change in order that I have a dynamical bin width?

Thank you for your help!


Solution

  • To have equal spaces you need to use the powers of 10 for bin sizes such as:

    x = abs.(randn(10000))
    y = abs.(randn(10000))
    using Plots
    histogram2d(x, y, xscale=:log10, yscale=:log10, bins=(10 .^(-2:.2:1), 10 .^(-2:.2:1)))
    

    enter image description here