A (somewhat) undocumented feature (and is not guaranteed to work in the
future!) is the axis's _axinfo dictionary.
# This is a temporary member variable.
# Do not depend on this existing in future releases!
self._axinfo = self._AXINFO[adir].copy()
self._axinfo.update({'label' : {'space_factor': 1.6,
'va': 'center',
'ha': 'center'},
'tick' : {'inward_factor': 0.2,
'outward_factor': 0.1},
'ticklabel': {'space_factor': 0.7},
'axisline': {'linewidth': 0.75,
'color': (0, 0, 0, 1)},
'grid' : {'color': (0.9, 0.9, 0.9, 1),
'linewidth': 1.0},
})
where _AXINFO is a class-level attribute defined as:
# Some properties for the axes
_AXINFO = {
'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2),
'color': (0.95, 0.95, 0.95, 0.5)},
'y': {'i': 1, 'tickdir': 0, 'juggled': (0, 1, 2),
'color': (0.90, 0.90, 0.90, 0.5)},
'z': {'i': 2, 'tickdir': 0, 'juggled': (0, 2, 1),
'color': (0.925, 0.925, 0.925, 0.5)},
}
This information used to be hard-coded throughout the axis3d.py module. I
consolidated it all into this dictionary for each Axis3D instance. So, you
should be able to create your Axes3D object, and then do something like the
following:
ax = fig.gca(projection='3d')
ax.xaxis._axinfo['grid'].update({'color': 'r', 'linewidth': 2})
ax.xaxis._axinfo['color'] = 'white'
(Note: untested code!) I don't think the linestyle can be specified,
though. At some point, I probably should get the Axes3D.grid() function
defined to mess around with this _axinfo modify the _axinfo dictionary.
I hope that helps!
Ben Root
···
On Tue, Sep 17, 2013 at 4:25 AM, Nils Wagner <nils106@...982...> wrote:
Hi all,
How can I modify the grid linewidth and grid line color of an Axes3D
object ?
is it possible to use white instead of gray for the background color ?
The following snippet doesn't show the desired effect.
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10,8))
ax = fig.gca(projection='3d')
ax.grid(color='r',linestyle='-',linewdith=2)