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

Suggestion: set style with env var, and allow turning transparency off #35

Open
z0u opened this issue Sep 23, 2018 · 2 comments
Open

Suggestion: set style with env var, and allow turning transparency off #35

z0u opened this issue Sep 23, 2018 · 2 comments

Comments

@z0u
Copy link

z0u commented Sep 23, 2018

I've been trying to work around #33 by styling the background of the axes, but I now see that the figure is being forced to be transparent. It would be nice if there was a way to disable that.

More generally: Would it be feasible/sensible to use stylesheets instead of reversing the video? I.e, have an environment variable that takes a stylesheet name and overrides the colours based on that?

@henryiii
Copy link

Running into this too with scikit-hep/uproot-browser#33. Hardcoding forcing of this to transparent and wiping the face color makes it impossible to use on black terminals (or if you themed it white, then on white terminals). Shouldn't the face color part be removed, then just the transparent=True would remain (fine), letting users pick a background color or no color?

@henryiii
Copy link

Here's my hacky workaround:

def intercept(func: Callable[..., Any], *names: str) -> Callable[..., Any]:
    """
    Intercept function arguments and remove them
    """

    @functools.wraps(func)
    def new_func(*args: Any, **kwargs: Any) -> Any:
        for name in names:
            kwargs.pop(name)
        return func(*args, **kwargs)

    return new_func

if plt.get_backend() == r"module://itermplot":
    fm = plt.get_current_fig_manager()
    canvas = fm.canvas
    # Ideally this should only runs once
    canvas.__class__.print_figure = intercept(
        canvas.__class__.print_figure, "facecolor", "edgecolor"
    )

plt.show()

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

2 participants