Python Matplotlib动画堆栈记号和记号标签

Python Matplotlib动画堆栈记号和记号标签,python,matplotlib,animation,label,axes,Python,Matplotlib,Animation,Label,Axes,我正在尝试使用Matplotlib(v3.3.2)制作一个简单的动画。动画效果很好,但一些记号和记号标签似乎堆叠在一起,模糊了字体 代码本身相当标准: import numpy as np import matplotlib.pyplot as plt from matplotlib import animation, rc # First set up the figure, the axis, and the plot element we want to animate fig, ax

我正在尝试使用Matplotlib(v3.3.2)制作一个简单的动画。动画效果很好,但一些记号和记号标签似乎堆叠在一起,模糊了字体

代码本身相当标准:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation, rc

# First set up the figure, the axis, and the plot element we want to animate
fig, ax = plt.subplots()

ax.set_xlim(( 0, 2))
ax.set_ylim((-2, 2))

line, = ax.plot([], [], lw=2)

# initialization function: plot the background of each frame
def init():
    line.set_data([], [])
    return (line,)

# animation function. This is called sequentially
def animate(i):
    x = np.linspace(0, 2, 1000)
    y = np.sin(2 * np.pi * (x - 0.01 * i))
    line.set_data(x, y)
    return (line,)

# call the animator
anim = animation.FuncAnimation(fig, animate, init_func=init,
                           frames=100, interval=20, blit=False)
anim.save('./images/test_anim.gif', writer='imagemagick', fps=50)
这将生成以下gif,您可以在其中看到堆叠显示的记号和标签,就像在彼此的顶部重新绘制一样。


有没有消除这种影响的建议?

您可以控制dpi并检查它是否有帮助。见