更改 pandas 图的背景色 [英] Change pandas plot background color
本文介绍了更改 pandas 图的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以更改熊猫图的背景?
Is it possible to change the background in a pandas chart?
我想将背景从白色和线条更改为橙色,但是我找不到任何相关文档.
I would like to change the background from white and the line to orange but I cannot find any documentation to do that.
我正在按以下方式使用熊猫:
I am using the pandas as follows:
import pandas.io.data as web
import numpy as np
gs = web.get_data_yahoo('gs')['Close']
gs = gs.pct_change()
gs.plot()
是否可以将背景更改为黑色或其他任何颜色?
Is it possible to change the background to black or any other color?
推荐答案
plot()
建立在 matplotlib
上.正确的方法是访问绘图轴对象并更改其bgcolor:将最后几行更改为:
plot()
in pandas
are build on matplotlib
. The right way is just to access the plot axes object and change its bgcolor: change the lastlines to:
P=gs.plot()
P.set_axis_bgcolor('g') #or any HTML colorcode, (R,G,B) tuple, (R,G,B,A) tuple, etcetc.
这篇关于更改 pandas 图的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文