Giter Club home page Giter Club logo

Comments (5)

hamzahanif2210 avatar hamzahanif2210 commented on June 18, 2024

have this feature been included or not?

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 18, 2024

Hi @hamzahanif2210, this is not currently implemented. If you'd like to work on the feature, I'd ask you to give a quick sketch here on what API and look you'd imagine for it.

from mplhep.

danielhundhausen avatar danielhundhausen commented on June 18, 2024

Hi @andrzejnovak , I'd be happy to work on this. As a standalone function something like this would work:

def errorband(
    H_band,  # value array if error band is symmetric / tuple of upper and lower value arrays
    bins,  # corresponding to bin edges of the hist values supplied in H_band
    label=None,
    edges=True,
    ax=None,
    **kwargs,
):
    # ax check
    if ax is None:
        ax = plt.gca()
    else:
        if not isinstance(ax, plt.Axes):
            raise ValueError("ax must be a matplotlib Axes object")

    # Construction of upper and lower boundries
    if isinstance(H_band, tuple):
        y_upper = H_band[0]
        y_lower = H_band[1]
    if isinstance(H_band, np.ndarray):
        y_upper = H_band
        y_lower = -y_upper

    error_band_args = { 
        "edges": bins, "facecolor": "none", "linewidth": 0,
        "alpha": .9, "color": "black", "hatch": "///"
    }   
    ax.stairs(y_upper, baseline=y_lower, label=label, **{**error_band_args, **kwargs})

Please let me know your thoughts.

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 18, 2024

Welcome, @danielhundhausen! I think I was originally thinking that this could be an option in histplot along the line of histplot(histtype='band'), where the band could be determined either by setting yerr or automatically from the existing weights methods. Is there a reason why you'd say it would be better as a separate function?

from mplhep.

danielhundhausen avatar danielhundhausen commented on June 18, 2024

Thank you for your comments @andrzejnovak ! I made a PR #414 that includes the integration of errorbands in histplot when plotting with histtype="fill", which is the standard use case, I think.
Regarding your question about making a separate function for the plotting - I think it reduces complexity of the code to split things into separate functions whenever possible. For the integration in histplot I have tried to follow the pattern of errorbar.

from mplhep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.