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

support for GTK3Cairo backend (AttributeError in get_renderer) #53

Open
malikbenkirane opened this issue Jun 8, 2018 · 1 comment
Open

Comments

@malikbenkirane
Copy link

Hi,

I found with GTK3Cairo backend FigureCanvas has neither fig.canvas.get_renderer() nor fig.canvas.renderer. I changed the code (at __init__.py line 35) so I could use this

def get_renderer(fig):
    try:
        return fig.canvas.get_renderer()
    except AttributeError:
        try:
            return fig.canvas.renderer
        except AttributeError:
            return fig.canvas._renderer

and get rid of

AttributeError: 'FigureCanvasGTK3Cairo' object has no attribute 'renderer'

As I don't feel this is a clean patch and I want to discuss before submitting a pull request. I also seen there were an issue with macos backend and I guess the first try statement is there for that reason. I would suggest hasattr or isinstance tests but there could be a clean a way I'm not aware. Any suggestions ?

@Phlya
Copy link
Owner

Phlya commented Jun 8, 2018

Hi, thanks for reporting this. An annoying problem... I would re-write it according to your hasattr suggestion to avoid deeply nested indentations, especially if there are some backends with other inconsistent behaviour. But if you could also report this to matplotlib devs it would be helpful in the long run, this might just be an inconsistency they could easily fix.

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