Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib Darker Background in 3D Plot

Tags:

matplotlib

I am plotting the following image in matplotlib. My problem is that, the image looks good like this, however, I would like to make the background darker, as when I print this image, the grayscale part does not appear in the print. Could someone tell me API to make this change?

I use simple API to plot the 3D curve -

ax.plot(X1, Y1, Z1, '^', c='r')
ax.plot(X2, Y2, Z2, 'o', c='b')

enter image description here

What I also tried is this -

fig = plt.figure(figsize=(10,10))
ax = fig.gca(projection='3d',  axisbg='gray')

This changes the color to dark gray, but it is also changing the colour outside the image -

enter image description here

like image 774
Raj Avatar asked Jan 15 '13 09:01

Raj


1 Answers

I achieved it by using following code -

ax = fig.add_subplot(111, projection='3d')
plt.gca().patch.set_facecolor('white')
ax.w_xaxis.set_pane_color((0.8, 0.8, 0.8, 1.0))
ax.w_yaxis.set_pane_color((0.8, 0.8, 0.8, 1.0))
ax.w_zaxis.set_pane_color((0.8, 0.8, 0.8, 1.0))
like image 187
Raj Avatar answered Nov 11 '22 03:11

Raj