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

GTK3Cairo Backend Legend TypeError #12892

Closed
zeroSteiner opened this issue Nov 26, 2018 · 1 comment
Closed

GTK3Cairo Backend Legend TypeError #12892

zeroSteiner opened this issue Nov 26, 2018 · 1 comment

Comments

@zeroSteiner
Copy link
Contributor

Bug report

When creating a legend with a pie graph using the GTK3Cairo backend a TypeError is raised. The issue affects versions 3.0.0rc2, 3.0.0, 3.0.1, 3.0.2 but not 2.2.3. Likewise this exception is not raised with the backend is GTK3Agg.

Code for reproduction

import matplotlib
matplotlib.rcParams['backend'] = 'GTK3Cairo'
import matplotlib.pyplot as plt

fig1, ax1 = plt.subplots()
ax1.pie(
	(83, 14, 2),
	colors=(
		(0.75, 0.86, 1.0),
		(0.49, 0.61, 0.73),
		(0.24, 0.36, 0.47)
	)
)
legend_bbox = fig1.legend(['Sample Text'])
legend_bbox.legendPatch.set_linewidth(0)
plt.show()

Actual outcome

Traceback (most recent call last):
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 33, in on_draw_event
    self._render_figure(allocation.width, allocation.height)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 21, in _render_figure
    self.figure.draw(self._renderer)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/figure.py", line 1649, in draw
    renderer, self, artists, self.suppressComposite)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/legend.py", line 646, in draw
    self.legendPatch.draw(renderer)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/patches.py", line 535, in draw
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_cairo.py", line 239, in draw_path
    _append_path(ctx, path, transform, clip)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_cairo.py", line 163, in _append_path
    return _append_paths(ctx, [path], [transform], clip)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_cairo.py", line 104, in _append_paths_slow
    *np.concatenate([cur / 3 + points[:2] * 2 / 3,
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'
Traceback (most recent call last):
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 33, in on_draw_event
    self._render_figure(allocation.width, allocation.height)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 21, in _render_figure
    self.figure.draw(self._renderer)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/figure.py", line 1649, in draw
    renderer, self, artists, self.suppressComposite)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/legend.py", line 646, in draw
    self.legendPatch.draw(renderer)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/patches.py", line 535, in draw
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_cairo.py", line 239, in draw_path
    _append_path(ctx, path, transform, clip)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_cairo.py", line 163, in _append_path
    return _append_paths(ctx, [path], [transform], clip)
  File "<redacted>/.venv/lib/python3.6/site-packages/matplotlib/backends/backend_cairo.py", line 104, in _append_paths_slow
    *np.concatenate([cur / 3 + points[:2] * 2 / 3,
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'

Expected outcome

The expected outcome is that a legend with the text "Sample Text" would be displayed and there would be no stack trace.

Matplotlib version

  • Operating system: Fedora 28 x64
  • Matplotlib version: 3.0.2 (Installed from PyPi with PIP)
  • Matplotlib backend (print(matplotlib.get_backend())): GTK3Cairo
  • Python version: 3.6
  • Jupyter version (if applicable): N/A
  • Other libraries: N/A
@QuLogic
Copy link
Member

QuLogic commented Nov 26, 2018

I believe this is a duplicate of #12794, which is fixed by #12795 for 3.0.3.

On Fedora 28, you can fix it by installing python3-cairocffi.

@QuLogic QuLogic closed this as completed Nov 26, 2018
@QuLogic QuLogic added this to the v3.0.3 milestone Nov 26, 2018
teto added a commit to teto/pymptcpanalyzer that referenced this issue Mar 11, 2019
because of this bug:
*np.concatenate([cur / 3 + points[:2] * 2 / 3,
see
matplotlib/matplotlib#12892
teto added a commit to teto/pymptcpanalyzer that referenced this issue Apr 16, 2019
because of this bug:
*np.concatenate([cur / 3 + points[:2] * 2 / 3,
see
matplotlib/matplotlib#12892
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants