Add a legend for an animation (of Artists) in matplotlib

后端 未结 1 1829
时光取名叫无心
时光取名叫无心 2021-01-21 11:08

I have made an animation from a set of images like this (10 snapshots):

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
         


        
1条回答
  •  有刺的猬
    2021-01-21 11:54

    If for whatever reason you need a legend, you can show your Circle as the handle and use some text as the label.

    ax.legend(handles=[cir], labels=["{}".format(frame_counter)])
    

    If you don't really need a legend, you can just use some text to place inside the axes.

    ax.text(.8,.8, "{}".format(frame_counter), transform=ax.transAxes)
    

    0 讨论(0)
提交回复
热议问题