Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f9fdff

Browse filesBrowse files
committed
Add support for minor ticks in 3d axes.
The actual implementation is shorter than deleting the copies of "Minor ticks are not supported" in the various docstrings...
1 parent e8b40f9 commit 8f9fdff
Copy full SHA for 8f9fdff

File tree

Expand file treeCollapse file tree

5 files changed

+24
-21
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+24
-21
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3D axes now support minor ticks
2+
```````````````````````````````

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,6 @@ def set_zticks(self, *args, **kwargs):
862862
Set z-axis tick locations.
863863
See :meth:`matplotlib.axes.Axes.set_yticks` for more details.
864864
865-
.. note::
866-
Minor ticks are not supported.
867-
868865
.. versionadded:: 1.1.0
869866
"""
870867
return self.zaxis.set_ticks(*args, **kwargs)
@@ -874,9 +871,6 @@ def get_zticks(self, minor=False):
874871
Return the z ticks as a list of locations
875872
See :meth:`matplotlib.axes.Axes.get_yticks` for more details.
876873
877-
.. note::
878-
Minor ticks are not supported.
879-
880874
.. versionadded:: 1.1.0
881875
"""
882876
return self.zaxis.get_ticklocs(minor=minor)
@@ -894,10 +888,6 @@ def get_zminorticklabels(self):
894888
"""
895889
Get the ztick labels as a list of Text instances
896890
897-
.. note::
898-
Minor ticks are not supported. This function was added
899-
only for completeness.
900-
901891
.. versionadded :: 1.1.0
902892
"""
903893
return cbook.silent_list('Text zticklabel',
@@ -908,9 +898,6 @@ def set_zticklabels(self, *args, **kwargs):
908898
Set z-axis tick labels.
909899
See :meth:`matplotlib.axes.Axes.set_yticklabels` for more details.
910900
911-
.. note::
912-
Minor ticks are not supported by Axes3D objects.
913-
914901
.. versionadded:: 1.1.0
915902
"""
916903
return self.zaxis.set_ticklabels(*args, **kwargs)
@@ -920,9 +907,6 @@ def get_zticklabels(self, minor=False):
920907
Get ztick labels as a list of Text instances.
921908
See :meth:`matplotlib.axes.Axes.get_yticklabels` for more details.
922909
923-
.. note::
924-
Minor ticks are not supported.
925-
926910
.. versionadded:: 1.1.0
927911
"""
928912
return cbook.silent_list('Text zticklabel',

‎lib/mpl_toolkits/mplot3d/axis3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axis3d.py
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,17 @@ def get_tick_positions(self):
140140
def get_major_ticks(self, numticks=None):
141141
ticks = maxis.XAxis.get_major_ticks(self, numticks)
142142
for t in ticks:
143-
t.tick1line.set_transform(self.axes.transData)
144-
t.tick2line.set_transform(self.axes.transData)
145-
t.gridline.set_transform(self.axes.transData)
146-
t.label1.set_transform(self.axes.transData)
147-
t.label2.set_transform(self.axes.transData)
143+
for obj in [
144+
t.tick1line, t.tick2line, t.gridline, t.label1, t.label2]:
145+
obj.set_transform(self.axes.transData)
146+
return ticks
147+
148+
def get_minor_ticks(self, numticks=None):
149+
ticks = maxis.XAxis.get_minor_ticks(self, numticks)
150+
for t in ticks:
151+
for obj in [
152+
t.tick1line, t.tick2line, t.gridline, t.label1, t.label2]:
153+
obj.set_transform(self.axes.transData)
148154
return ticks
149155

150156
def set_pane_pos(self, xys):
Loading

‎lib/mpl_toolkits/tests/test_mplot3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/tests/test_mplot3d.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,3 +903,14 @@ def test_ax3d_tickcolour():
903903
assert tick.tick1line._color == 'red'
904904
for tick in ax.zaxis.get_major_ticks():
905905
assert tick.tick1line._color == 'red'
906+
907+
908+
@image_comparison(["minor_ticks.png"], style="default")
909+
def test_minor_ticks():
910+
ax = plt.figure().add_subplot(projection="3d")
911+
ax.set_xticks([0.25], minor=True)
912+
ax.set_xticklabels(["quarter"], minor=True)
913+
ax.set_yticks([0.33], minor=True)
914+
ax.set_yticklabels(["third"], minor=True)
915+
ax.set_zticks([0.50], minor=True)
916+
ax.set_zticklabels(["half"], minor=True)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.