itermplot icon indicating copy to clipboard operation
itermplot copied to clipboard

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

Open z0u opened this issue 7 years ago • 2 comments

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?

z0u avatar Sep 23 '18 07:09 z0u

Running into this too with https://github.com/henryiii/uproot-browser/issues/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 avatar Mar 17 '22 20:03 henryiii

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()

henryiii avatar Mar 17 '22 20:03 henryiii