JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.83k stars 354 forks source link

Polar histogram issue #1952

Open pierrethiriet opened 5 years ago

pierrethiriet commented 5 years ago

I am trying to plot wind direction histogram with a polar projection. With a low number of data, the histogram is not plotted correctly (Julia 1.1, Plots : 0.23.1)

# Generate angle values
val = randn(100_000)
val = val .- minimum(val)
val = val ./ maximum(val)
Θ = deg2rad.(val .* 360)

# Histogram
histogram(Θ, seriestype=:histogram, nbins=30, proj=:polar, yflip = true)

wr_small While with a higher number of values, the results are correct:

# Generate angle values
val = randn(10_000_000)
val = val .- minimum(val)
val = val ./ maximum(val)
Θ = deg2rad.(val .* 360)

# Histogram
histogram(Θ, seriestype=:histogram, nbins=30, proj=:polar, yflip = true)

wr_big

Thanks

mkborregaard commented 5 years ago

Ugh sorry. You can sidestep the problem by using stephist(Θ, nbins=30, proj=:polar, yflip = true) ( the seriestype arg is redundant.

pierrethiriet commented 5 years ago

Thanks a lot, it works perfectly regardless of the sample size! (even though I am not 100% sure to understand why). Now remain the question of the plot orientation, 0° = North, not on the top, but that another issue already raised elsewhere.