Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the background color of the axes planes of a matplotlib 3D plot

On the basis of the scatterplot example of matplotlib, how can I change the gray background color of the 3 axes grid planes? I would like to set it to white, keeping the grid lines with the default gray color. I found this question but I couldn't apply it to the example. Thanks.

like image 674
user1520280 Avatar asked Jul 12 '12 09:07

user1520280


People also ask

How do I change the background color in Matplotlib?

Matplotlib change background color inner and outer colorset_facecolor() method is used to change the inner background color of the plot. figure(facecolor='color') method is used to change the outer background color of the plot. In the above example, we have change both an inner and outer color of background of plot.

Are 3D graphs possible in Matplotlib?

Matplotlib was introduced keeping in mind, only two-dimensional plotting. But at the time when the release of 1.0 occurred, the 3d utilities were developed upon the 2d and thus, we have 3d implementation of data available today! The 3d plots are enabled by importing the mplot3d toolkit.

How do you plot a 3D scatter plot in Python?

Generally 3D scatter plot is created by using ax. scatter3D() the function of the matplotlib library which accepts a data sets of X, Y and Z to create the plot while the rest of the attributes of the function are the same as that of two dimensional scatter plot.


1 Answers

Using the same example. You can set the pane color using the set_pane_color method as described here http://matplotlib.org/mpl_toolkits/mplot3d/api.html#axis3d. You can set the color using the RGBA tuple:

# scatter3d_demo.py # ... # Set the background color of the pane YZ ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 1.0)) plt.show() 
like image 96
Pablo Navarro Avatar answered Oct 30 '22 04:10

Pablo Navarro