How to change the background color of df.plot() in Python Pandas?
Question:
I want to specify the color of the area surrounding a plot created using the df.plot()
in Pandas/Python.
Using .set_facecolor
as in the code below only changes the area inside the axes (see image), I want to change the color outside too.
import pandas as pd
import numpy as np
df = pd.DataFrame(components, columns=['PC1','PC2']
df.plot('PC1','PC2','scatter').set_facecolor('green')
Replacing the last line with these two lines produces the same graph.
ax = df.plot('PC1','PC2','scatter')
ax.set_facecolor('green')
Answers:
I want to specify the color of the area surrounding a plot created using the df.plot()
in Pandas/Python.
Using .set_facecolor
as in the code below only changes the area inside the axes (see image), I want to change the color outside too.
import pandas as pd
import numpy as np
df = pd.DataFrame(components, columns=['PC1','PC2']
df.plot('PC1','PC2','scatter').set_facecolor('green')
Replacing the last line with these two lines produces the same graph.
ax = df.plot('PC1','PC2','scatter')
ax.set_facecolor('green')