Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

from collections import defaultdict
from functools import partialmethod
import itertools
import math
import textwrap
Expand Down Expand Up @@ -1196,6 +1197,17 @@ def set_zscale(self, value, **kwargs):
"""
self._set_axis_scale(self.zaxis, value, **kwargs)

def _raise_semilog_not_implemented(self, name, *args, **kwargs):
raise NotImplementedError(
f"Axes3D does not support {name}. Use ax.set_xscale/set_yscale/set_zscale "
"and ax.plot(...) instead."
)

semilogx = partialmethod(_raise_semilog_not_implemented, "semilogx")
semilogy = partialmethod(_raise_semilog_not_implemented, "semilogy")
semilogz = partialmethod(_raise_semilog_not_implemented, "semilogz")
loglog = partialmethod(_raise_semilog_not_implemented, "loglog")

get_zticks = _axis_method_wrapper("zaxis", "get_ticklocs")
set_zticks = _axis_method_wrapper("zaxis", "set_ticks")
get_zmajorticklabels = _axis_method_wrapper("zaxis", "get_majorticklabels")
Expand Down
9 changes: 9 additions & 0 deletions lib/mpl_toolkits/mplot3d/tests/test_axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3169,6 +3169,15 @@ def test_scale3d_autoscale_with_log():
assert lim[1] > 0, f"{name} upper limit should be positive"


@pytest.mark.parametrize("method", ["semilogx", "semilogy", "semilogz", "loglog"])
def test_semilog_loglog_not_implemented(method):
"""semilogx/y/z and loglog should raise NotImplementedError on Axes3D."""
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
with pytest.raises(NotImplementedError, match="Axes3D does not support"):
getattr(ax, method)([1, 10, 100], [1, 2, 3])


def test_scale3d_calc_coord():
"""_calc_coord should return data coordinates with correct pane values."""
fig = plt.figure()
Expand Down
Loading