Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found an error in when dealing with step plots #37

Open
AlvaroNovillo opened this issue Feb 14, 2024 · 0 comments
Open

Found an error in when dealing with step plots #37

AlvaroNovillo opened this issue Feb 14, 2024 · 0 comments

Comments

@AlvaroNovillo
Copy link

Hi! Your current module does only support step plots with the variable where = ''pre" (which is the default value, as indicated in the documentation. I've changed the code so that the user can input the parameter themselves in order to fix it, but this is not the optimal solution. Could you fix that in the next version?

def make_lines_glow(ax=None, n_glow_lines=10, diff_linewidth=1.05, alpha_line=0.3, where=None):
"""Add a glow effect to the lines in an axis object.

            Each existing line is redrawn several times with increasing width and low alpha to create the glow effect.
            """
            if not ax:
                ax = plt.gca()
        
            lines = ax.get_lines()
        
            alpha_value = alpha_line / n_glow_lines
        
            for line in lines:
                data = line.get_data()
                linewidth = line.get_linewidth()
                
                try:
                    step_type = line.get_drawstyle().split('-')[1]
                except:
                    step_type = None
        
                for n in range(1, n_glow_lines + 1):
                    if step_type:
                        # Use the 'where' parameter if it's provided
                        if where is not None:
                            glow_line, = ax.step(*data, where=where)
                        else:
                            glow_line, = ax.step(*data)
                    else:
                        glow_line, = ax.plot(*data)
                    glow_line.update_from(line)
        
                    glow_line.set_alpha(alpha_value)
                    glow_line.set_linewidth(linewidth + (diff_linewidth * n))
                    glow_line.is_glow_line = True

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant