Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: backend_cairo set_context() is broken for cairocffi #26523

Copy link
Copy link
Closed
@dmatth

Description

@dmatth
Issue body actions

Bug summary

Saving an SVG via cairocffi this way worked in 3.5.2, but fails in 3.6.x - 3.7.2 .
I see though that it's just a cairocffi issue; switching to pycairo seems to work so for now I will give that a try.

Code for reproduction

import sys
import matplotlib
from matplotlib import pyplot as plt


def main(argv):
    matplotlib.use("cairo")
    fig, axs = plt.subplots(1, 8, figsize=(8.0, 4.0), facecolor="w", edgecolor="k")

    dump_to = "whatever.svg"
    plt.savefig(dump_to)


if __name__ == '__main__':
    main(sys.argv)

Actual outcome

  File ".../.venv/lib/python3.11/site-packages/matplotlib/backends/backend_cairo.py", line 484, in _save
    self._renderer.set_context(cairo.Context(surface))
  File ".../.venv/lib/python3.11/site-packages/matplotlib/backends/backend_cairo.py", line 99, in set_context
    size = rect.width, rect.height
           ^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'width'

Expected outcome

savefig should save the fig

Additional information

this is with:
matplotlib==3.7.2
cairocffi==1.6.1
and the brew install of cairo 1.16.0_5

Operating system

macOS

Matplotlib Version

3.7.2

Matplotlib Backend

cairo

Python version

3.11.4

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.