matlab 蜡烛图 颜色,Matplotlib图facecolor(背景颜色)

Matplotlib图facecolor(背景颜色)

有人可以解释为什么下面的代码在设置graphics的facecolor时不起作用吗?

import matplotlib.pyplot as plt # create figure instance fig1 = plt.figure(1) fig1.set_figheight(11) fig1.set_figwidth(8.5) rect = fig1.patch rect.set_facecolor('red') # works with plt.show(). # Does not work with plt.savefig("trial_fig.png") ax = fig1.add_subplot(1,1,1) x = 1, 2, 3 y = 1, 4, 9 ax.plot(x, y) # plt.show() # Will show red face color set above using rect.set_facecolor('red') plt.savefig("trial_fig.png") # The saved trial_fig.png DOES NOT have the red facecolor. # plt.savefig("trial_fig.png", facecolor='red') # Here the facecolor is red.

当我使用fig1.set_figheight(11) fig1.set_figwidth(8.5)指定graphics的高度和宽度时,这些命令由plt.savefig("trial_fig.png")命令plt.savefig("trial_fig.png") 。 但是,facecolor设置不拾起。 为什么?

谢谢你的帮助。

这是因为savefig覆

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值