Matplotlib figure facecolor (background color)

前端 未结 4 698
無奈伤痛
無奈伤痛 2020-11-27 13:05

Can someone please explain why the code below does not work when setting the facecolor of the figure?

import matplotlib.pyplot as plt

# create figure instan         


        
4条回答
  •  离开以前
    2020-11-27 13:44

    savefig has its own parameter for facecolor. I think an even easier way than the accepted answer is to set them globally just once, instead of putting facecolor=fig.get_facecolor() every time:

    plt.rcParams['axes.facecolor']='red'
    plt.rcParams['savefig.facecolor']='red'
    

提交回复
热议问题