JuliaTeX / PGFPlots.jl

This library uses the LaTeX package pgfplots to produce plots.
Other
188 stars 36 forks source link

Add bin width specification for Histogram plots (LOW PRIORITY) #178

Open lkruse opened 3 years ago

lkruse commented 3 years ago

It would be pretty neat if Histogram plots accepted a parameter for a fixed bin width - or alternatively, accepted an array of values representing bin edges, as the Matplotlib implementation does:

bins: int or sequence or str, default: rcParams["hist.bins"] (default: 10)
    If bins is an integer, it defines the number of equal-width bins in the range.

    If bins is a sequence, it defines the bin edges, including the left edge of the first bin and the right edge of the last bin; in this 
    case, bins may be unequally spaced. All but the last (righthand-most) bin is half-open. 

Such a feature would promote more consistent visuals and facilitate comparison when attempting to overlay histograms:

define_color("vandeusen", [73,92,111])
define_color("cordovan", [152,68,71])

X1 = randn(100) .+= 2.0   
X2 = 4*randn(100)

p = Axis([
    Plots.Histogram(X1, density=true, 
                    style="vandeusen, fill=vandeusen,opacity=0.5"),
    Plots.Histogram(X2, density=true, 
                    style="cordovan, fill=cordovan,opacity=0.5")
],
ymin=0, ylabel="Density", xlabel = "X")

bin_size

Definitely a low-priority issue though!