1

I don't know why there will be a grey frame automatically in my chart. I want to set my chart all white and with a black frame and grid.

fig = plt.figure()
fig.set_facecolor('none')
plt.rcParams['axes.facecolor'] = 'none'
ax1 = fig.add_subplot(111)
ax1.set_title('Druck')
plt.xlabel('L/D')
plt.ylabel('$Q_{CPT}/Q_{API}$')
plt.ylim((0,4.5))
plt.xlim((0,40))
plt.scatter(x1,y1, c='b', label='UWA-05')
plt.scatter(x2,y2,c='r', label='ICP-05')
plt.grid(axis='y', c='black',alpha=0.8)
plt.grid(axis='x', c='black',alpha=0.8)
plt.legend()
leg = plt.legend()
leg.get_frame().set_edgecolor('none')
plt.show()

chart with the weird grey frame

Georgy
  • 12,464
  • 7
  • 65
  • 73
It's Nele
  • 75
  • 2
  • 9

1 Answers1

1

add these lines, obviously change the background colour to whatever you want

 bg_color = 'black'
 ax1.patch.set_facecolor(bg_color)

also change this:

leg.get_frame().set_edgecolor('Black') #<---- change 'none' to 'Black'
EcSync
  • 842
  • 1
  • 6
  • 20