Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Bug]: BufferRegion get_extents does not return negative values #23491

Open
@hugochrist1

Description

@hugochrist1

Bug summary

Calling get_extents on a BufferRegion returns the values as unsigned ints so if the region was outside of the canvas, they are incorrect.
The y-axis increases downwards.

Code for reproduction

importmatplotlib.pyplotaspltfrommatplotlib.transformsimportBboximportstructfig=plt.figure()canvas=fig.canvasw,h=canvas.get_width_height()br=canvas.copy_from_bbox(Bbox.from_extents(-10,h-1,10,h+1))ext=br.get_extents()print(ext,struct.unpack('iiii',struct.pack('IIII',*ext)))

Actual outcome

(4294967286, 4294967295, 10, 1) (-10, -1, 10, 1)

Expected outcome

(-10, -1, 10, 1)

Additional information

I think the problem comes from this:
https://github.com/matplotlib/matplotlib/blob/main/src/_backend_agg_wrapper.cpp#L77

static PyObject *PyBufferRegion_get_extents(PyBufferRegion *self, PyObject *args){    agg::rect_i rect = self->x->get_rect();    return Py_BuildValue("IIII", rect.x1, rect.y1, rect.x2, rect.y2);}

Replacing 'IIII' with 'iiii' would solve it

Operating system

Windows 10

Matplotlib Version

3.5.2

Matplotlib Backend

TkAgg

Python version

3.10.4

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp