Content-Length: 312225 | pFad | http://github.com/matplotlib/matplotlib/issues/29300

D3 [Bug]: Background of rotated png is rendered black · Issue #29300 · matplotlib/matplotlib · GitHub
Skip to content

[Bug]: Background of rotated png is rendered black #29300

@maederan201

Description

@maederan201

Bug summary

If I rotate an image, the background of its bounding box is rendered black when rendering as .pdf or .png

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.transforms import Affine2D
import numpy as np

img = np.random.random((100, 20, 3))

tr_rotate = Affine2D().rotate_deg_around(0 / 2, 0 / 2, 45)
tr_translate = Affine2D().translate(250, 250)

fig, ax = plt.subplots()

ax.imshow(
    img,
    transform=tr_rotate + ax.transData,
    clip_on=False,
)

ax.imshow(
    img,
    transform=tr_translate + ax.transData,
    clip_on=False,
)

ax.set_xlim(-250, 500)
ax.set_ylim(-250, 500)

fig.savefig("MWE.png")

Actual outcome

Image

Expected outcome

Transparent Bounding Box

Additional information

In the past this was possible, however I don't know which version of matplotlib was used...

Operating system

KDE Neon

Matplotlib Version

3.9.2

Matplotlib Backend

tkagg

Python version

3.12.3

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/matplotlib/matplotlib/issues/29300

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy