5959from . import axis3d
6060
6161
62+ class UnsupportedError (RuntimeError ):
63+ """
64+ Raised on Axes3D methods that are inherited from Axes, but not supported by Axes3D.
65+ """
66+
67+
6268@_docstring .interpd
6369@_api .define_aliases ({
6470 "xlim" : ["xlim3d" ], "ylim" : ["ylim3d" ], "zlim" : ["zlim3d" ]})
@@ -71,6 +77,11 @@ class Axes3D(Axes):
7177 As a user, you do not instantiate Axes directly, but use Axes creation
7278 methods instead; e.g. from `.pyplot` or `.Figure`:
7379 `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` or `.Figure.add_axes`.
80+
81+ .. note::
82+
83+ Some of the inherited behavior of Axes is not applicable to 3d and will raise
84+ an `.UnsupportedError`.
7485 """
7586 name = '3d'
7687
@@ -1197,16 +1208,24 @@ def set_zscale(self, value, **kwargs):
11971208 """
11981209 self ._set_axis_scale (self .zaxis , value , ** kwargs )
11991210
1200- def _raise_semilog_not_implemented (self , name , * args , ** kwargs ):
1201- raise NotImplementedError (
1202- f"Axes3D does not support { name } . Use ax.set_xscale/set_yscale/set_zscale "
1203- "and ax.plot(...) instead."
1211+ def _raise_unsupported (self , name , * args , ** kwargs ):
1212+ raise UnsupportedError (f"Axes3D does not support '{ name } '." )
1213+
1214+ twinx = partialmethod (_raise_unsupported , "twinx" )
1215+ twiny = partialmethod (_raise_unsupported , "twiny" )
1216+ secondary_xaxis = partialmethod (_raise_unsupported , "secondary_xaxis" )
1217+ secondary_yaxis = partialmethod (_raise_unsupported , "secondary_yaxis" )
1218+
1219+ def _raise_semilog_unsupported (self , name , * args , ** kwargs ):
1220+ raise UnsupportedError (
1221+ f"Axes3D does not support '{ name } '. "
1222+ "Use ax.set_xscale/set_yscale/set_zscale and ax.plot(...) instead."
12041223 )
12051224
1206- semilogx = partialmethod (_raise_semilog_not_implemented , "semilogx" )
1207- semilogy = partialmethod (_raise_semilog_not_implemented , "semilogy" )
1208- semilogz = partialmethod (_raise_semilog_not_implemented , "semilogz" )
1209- loglog = partialmethod (_raise_semilog_not_implemented , "loglog" )
1225+ semilogx = partialmethod (_raise_semilog_unsupported , "semilogx" )
1226+ semilogy = partialmethod (_raise_semilog_unsupported , "semilogy" )
1227+ semilogz = partialmethod (_raise_semilog_unsupported , "semilogz" )
1228+ loglog = partialmethod (_raise_semilog_unsupported , "loglog" )
12101229
12111230 get_zticks = _axis_method_wrapper ("zaxis" , "get_ticklocs" )
12121231 set_zticks = _axis_method_wrapper ("zaxis" , "set_ticks" )
0 commit comments