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

5
  • What platform are you running this code on? When I run it in Spyder as-is I see a black edge, not gray like in your picture. Commented Feb 5, 2019 at 11:27
  • Duplicate of stackoverflow.com/questions/14088687/… ? Commented Feb 5, 2019 at 11:30
  • @Brian I use spyder as well... Commented Feb 5, 2019 at 11:53
  • Are you using inline graphics? Maybe try using interactive plotting as shown here: stackoverflow.com/a/31488324/5626104 Commented Feb 5, 2019 at 11:59
  • @Brian Thanks a lot, this option is 'inline' already... Commented Feb 5, 2019 at 12:14

1 Answer 1

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' 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.