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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy