JuliaTeX / PGFPlots.jl

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

Add legendentry parameter to Histogram plots #177

Closed lkruse closed 2 years ago

lkruse commented 3 years ago

Legend entries can be entered via the legendentry command for Linear plots, as in the following example:

x = [1,2,3]
y = [2,4,1]
pushPGFPlotsOptions("scale=1.5")
a = Axis(Plots.Linear(x, y, legendentry="My Plot"), 
        xlabel="X", ylabel="Y", title="My Title")

legend_example

However, attempting to add a legendentry for a Histogram produces the following error:

d = randn(100)        
b = Axis(Plots.Histogram(d, bins=10, legendentry="My Plot"), ymin=0)
ERROR: LoadError: MethodError: no method matching PGFPlots.Plots.Histogram(::Vector{Float64}; bins=10, legendentry="My Plot")
Closest candidates are:
  PGFPlots.Plots.Histogram(::Any; bins, discretization, density, cumulative, style, texlabel) at /home/liam/.julia/packages/PGFPlots/HMdMV/src/plots.jl:83 got unsupported keyword argument "legendentry"
Stacktrace:
 [1] kwerr(::NamedTuple{(:bins, :legendentry), Tuple{Int64, String}}, ::Type, ::Vector{Float64})
   @ Base ./error.jl:157
 [2] top-level scope
   @ ~/T-ITS2021StochasticIDM/plots.jl:190
in expression starting at /home/liam/T-ITS2021StochasticIDM/plots.jl:190