30

Here is a code am trying to run:

ax = plt.axes(axisbg='#E6E6E6')
ax.set_axisbelow(True)
plt.grid(color='w',linestyle='solid')

for spine in ax.spines.values():
   spine.set_visible(False)

ax.xaxis.tick_bottom()
ax.yaxis.tick_left()

ax.tick_params(colors='gray',direction='out')
for tick in ax.get_xticklabels():
   tick.set_color('gray')
for tick in ax.get_yaxislabels():
   tick.set_color('gray')

ax.hist(x,edgecolor='E6E6E6',color='E6E6E6');

And the Error is: AttributeError: Unknown property axisbg

Please help me identify the error.

kmario23
  • 57,311
  • 13
  • 161
  • 150
Abhishek Kumar
  • 768
  • 1
  • 8
  • 23

2 Answers2

46

Replace the below line of code

ax = plt.axes(axisbg='#E6E6E6')

with

ax = plt.axes(facecolor='#E6E6E6')
kmario23
  • 57,311
  • 13
  • 161
  • 150
12

axisbg is deprecated in matplotlib 2.0+ Use facecolor instead.

https://matplotlib.org/api/api_changes.html

sohyal sawhney
  • 121
  • 1
  • 4