I'm currently using Pandas direct plot (df.plot) in Python 2.7. It has worked great except it leaves me with a gray background. Is it possible to modify this color (eg. set it to white?)
Thanks.
MatPlotLib with Python To change the axes background color, we can use set_facecolor() method.
Matplotlib change background color inner and outer colorset_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. In the above example, we have change both an inner and outer color of background of plot.
The easiest way to change the background color of a plot in Matplotlib is to use the set_facecolor() argument.
Sure
You can use the ax object the plot function returns.
my_df = pd.DataFrame({'A': range(0, 100), 'B': np.random.uniform(1, 100, 100)})
ax = my_df.plot(kind='scatter', x='A', y='B')
ax.set_facecolor('black')
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