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

Matplotlib - backgroud transparent #1935

Closed
mfnpvh opened this issue Mar 16, 2023 · 1 comment
Closed

Matplotlib - backgroud transparent #1935

mfnpvh opened this issue Mar 16, 2023 · 1 comment
Labels
lib-misc Issues pertaining to misc. 3rd-party libraries. question Questions regarding functionality, usage

Comments

@mfnpvh
Copy link

mfnpvh commented Mar 16, 2023

I'm using matplotlib in package Moviepy, I want to know is it possible make backgroud transparent with plotting bar.

import matplotlib.pyplot as plt
import numpy as np
from moviepy.editor import VideoClip
from moviepy.video.io.bindings import mplfig_to_npimage

x = np.linspace(-2, 2, 200)

duration = 2

fig, ax = plt.subplots()
def make_frame(t):
    ax.clear()
    ax.plot(x, np.sinc(x**2) + np.sin(x + 2*np.pi/duration * t), lw=3)
    ax.set_ylim(-1.5, 2.5)
    return mplfig_to_npimage(fig)

animation = VideoClip(make_frame, duration=duration)
animation.write_gif('matplotlib.gif', fps=20)

As far as I know, the method savefig has attribute transparent, but in this case, is it possible to make backgroud transparent?

@mfnpvh mfnpvh added the question Questions regarding functionality, usage label Mar 16, 2023
@keikoro keikoro added the lib-misc Issues pertaining to misc. 3rd-party libraries. label Apr 12, 2023
@OsaAjani
Copy link
Collaborator

Fixed with v2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib-misc Issues pertaining to misc. 3rd-party libraries. question Questions regarding functionality, usage
Projects
None yet
Development

No branches or pull requests

3 participants