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?
set_facecolor() method is used to change the inner background color of the plot. figure(facecolor='color') method is used to change the outer background color of the plot.
You can change the background color with ax. set_axis_bgcolor , but it will only change the area inside of the plot. This is useful when you have multiple plots in the same figure (a.k.a. multiple charts in the same image) but most of the time is just a headache.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With