I want to display the minor z ticks on an Axes3D plot without minor gridlines.
The starting figure looks like this:
The code is here:
import numpy as np
import matplotlib
from matplotlib.figure import Figure
test_fig = Figure()
_x = np.arange(4)
_y = np.arange(5)
_xx, _yy = np.meshgrid(_x, _y)
x, y = _xx.ravel(), _yy.ravel()
top = x + y
bottom = np.zeros_like(top)
width = depth = 1
test_ax = test_fig.add_subplot(111, projection='3d')
test_ax.bar3d(x, y, bottom, width, depth, top, shade=True, label='my label')
I've tried:
test_ax.zaxis.set_minor_locator(AutoMinorLocator())
Paired with several variations of the follow, trying to 'trick' Matplotlib to hide the minor grid lines:
test_ax.zaxis._axinfo['grid']['minor'] = {'linewidth': 0}
test_ax.zaxis._axinfo['grid']['minor'] = {'gridOn': False}
I'd prefer not to use protected members of Matplotlib (_axinfo
) if there's a reasonable way not to but at this point I'm open to nearly anything.
My latest attempt is to try to 'trick' Matplotlib:
test_ax.zaxis.set_minor_locator(AutoMinorLocator())
test_ax.zaxis.grid(visible=True, which='minor', alpha=0.0)
I tried changing the visible
argument to True
because when it's False
nothing changes. I tried changing the linewidth
, etc. with no results. The documentation for zaxis.grid()
is not as built out as other areas of the documentation, it's not helpful.
The latest attempt yields the following chart:
What should I try next?
I want to display the minor z ticks on an Axes3D plot without minor gridlines.
The starting figure looks like this:
The code is here:
import numpy as np
import matplotlib
from matplotlib.figure import Figure
test_fig = Figure()
_x = np.arange(4)
_y = np.arange(5)
_xx, _yy = np.meshgrid(_x, _y)
x, y = _xx.ravel(), _yy.ravel()
top = x + y
bottom = np.zeros_like(top)
width = depth = 1
test_ax = test_fig.add_subplot(111, projection='3d')
test_ax.bar3d(x, y, bottom, width, depth, top, shade=True, label='my label')
I've tried:
test_ax.zaxis.set_minor_locator(AutoMinorLocator())
Paired with several variations of the follow, trying to 'trick' Matplotlib to hide the minor grid lines:
test_ax.zaxis._axinfo['grid']['minor'] = {'linewidth': 0}
test_ax.zaxis._axinfo['grid']['minor'] = {'gridOn': False}
I'd prefer not to use protected members of Matplotlib (_axinfo
) if there's a reasonable way not to but at this point I'm open to nearly anything.
My latest attempt is to try to 'trick' Matplotlib:
test_ax.zaxis.set_minor_locator(AutoMinorLocator())
test_ax.zaxis.grid(visible=True, which='minor', alpha=0.0)
I tried changing the visible
argument to True
because when it's False
nothing changes. I tried changing the linewidth
, etc. with no results. The documentation for zaxis.grid()
is not as built out as other areas of the documentation, it's not helpful.
The latest attempt yields the following chart:
What should I try next?
Share Improve this question edited Mar 17 at 16:21 pippo1980 3,2013 gold badges17 silver badges40 bronze badges asked Mar 15 at 9:03 Python_LearnerPython_Learner 1,6774 gold badges25 silver badges55 bronze badges1 Answer
Reset to default 0Can only remove all z gridlines with:
test_ax.zaxis.gridlines.set_visible(False)
or
test_ax.zaxis._axinfo['grid']['linewidth'] = 0.0
in Matplotlib 3.8.4 (see Online Matplotlib Compiler )