FHist.jl
FHist.jl copied to clipboard
Plotting example using FHist and Plotly
Here is an example of how one might use FHist to make some real physics plots. I created a wrapper of PlotlyJS to format things in LHC physics plot style. (Because finding all the options in plotly takes some time.)
using PlotlyJSWrapper
using FHist
# Creating example histograms
h1 = Hist1D(randn(3000),-5:0.5:5)
h2 = Hist1D(randn(1000).+1,-5:0.5:5)
h3 = Hist1D((randn(1000).+2)./2,-5:0.5:5)
h4 = Hist1D((randn(2000).-2).*2,-5:0.5:5)
h5 = Hist1D(randn(2000).*5,-5:0.5:5)
h6 = Hist1D(randn(2000).-0.5,-5:0.5:5)
data = Hist1D(randn(9000),-5:0.5:5)
signal = Hist1D((randn(1000).+10)./3,-5:0.5:5)
# Plotting
plot_stack(
backgrounds=[h1, h2, h3, h4, h5, h6],
data=[data],
signals=[signal], # TODO Not supported yet
options=Dict{Symbol, Any}(
:xaxistitle => "Δϕ<sub>jj</sub> [GeV]",
:outputname => "plot.pdf",
:backgroundlabels => ["tt̄", "Higgs", "Drell-Yan", "tt̄Z", "ZZ", "VBS WW"],
:signallabels => ["VVH"],
)
)
This would produce https://github.com/sgnoohc/PlotlyJSWrapper.jl/blob/main/examples/example1/plot.png
Thanks, this looks really great, I saw the interactive plots too.
Just an FYI, the long term plan for this package (FHist) is to have recipe for Plots.jl (through RecipeBase.jl) and Makie.jl (their recipe system is still WIP), without directly depending on the heavy plotting packages themselves. Probably for plotting a single histogram and a Vector of Hist1Ds as stacked.
You could publish a PlotlyFHist.jl (pick a better name than I can) package that depends on FHist and whatever plotting tools you need and I will be more than happy to advertise this package because honestly it looks better than anything I've seen so far.
I'm happy to move PlotlyJSWrapper into ext/FHistPlotlyJS if @sgnoohc is okay?
What that would look like is similar to how currently FHist.jl supports Makie -- throug the Pkg.jl extention system.
This way, when user install FHist.jl and PlotlyJS.jl and use both, these functions will automatically get loaded and user can plot them easily.