Skip to content

Deprecate Axes3D.w_{x,y,z}axis in favor of .{x,y,z}axis. #11387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2019
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
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/2018-10-04-AL-deprecations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deprecations
````````````

``axes3d.Axes3D.w_xaxis``, ``.w_yaxis``, and ``.w_zaxis`` are deprecated (use
``.xaxis``, ``.yaxis``, and ``.zaxis`` instead).
2 changes: 1 addition & 1 deletion examples/mplot3d/surface3d_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@

# Customize the z axis.
ax.set_zlim(-1, 1)
ax.w_zaxis.set_major_locator(LinearLocator(6))
ax.zaxis.set_major_locator(LinearLocator(6))

plt.show()
4 changes: 2 additions & 2 deletions examples/pyplots/whats_new_1_subplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
linewidth=0, antialiased=False)
ax.set_zlim3d(-1.01, 1.01)

#ax.w_zaxis.set_major_locator(LinearLocator(10))
#ax.w_zaxis.set_major_formatter(FormatStrFormatter('%.03f'))
#ax.zaxis.set_major_locator(LinearLocator(10))
#ax.zaxis.set_major_formatter(FormatStrFormatter('%.03f'))

fig.colorbar(surf, shrink=0.5, aspect=5)

Expand Down
18 changes: 8 additions & 10 deletions lib/matplotlib/cbook/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ class MatplotlibDeprecationWarning(UserWarning):
def _generate_deprecation_warning(
since, message='', name='', alternative='', pending=False,
obj_type='attribute', addendum='', *, removal=''):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch doesn't change the logic, just clarifies that pending deprecations have no scheduled removal.

if removal == "":
removal = {"2.2": "in 3.1", "3.0": "in 3.2", "3.1": "in 3.3"}.get(
since, "two minor releases later")
elif removal:
if pending:
if pending:
if removal:
raise ValueError(
"A pending deprecation cannot have a scheduled removal")
removal = "in {}".format(removal)

else:
if removal:
removal = "in {}".format(removal)
else:
removal = {"2.2": "in 3.1", "3.0": "in 3.2", "3.1": "in 3.3"}.get(
since, "two minor releases later")
if not message:
message = (
"\nThe %(name)s %(obj_type)s"
Expand All @@ -46,10 +46,8 @@ def _generate_deprecation_warning(
+ "."
+ (" Use %(alternative)s instead." if alternative else "")
+ (" %(addendum)s" if addendum else ""))

warning_cls = (PendingDeprecationWarning if pending
else MatplotlibDeprecationWarning)

return warning_cls(message % dict(
func=name, name=name, obj_type=obj_type, since=since, removal=removal,
alternative=alternative, addendum=addendum))
Expand Down
20 changes: 15 additions & 5 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,28 @@ def _init_axis(self):
self.xy_dataLim.intervaly, self)
self.zaxis = axis3d.ZAxis('z', self.zz_viewLim.intervalx,
self.zz_dataLim.intervalx, self)
# Provide old aliases
self.w_xaxis = self.xaxis
self.w_yaxis = self.yaxis
self.w_zaxis = self.zaxis

for ax in self.xaxis, self.yaxis, self.zaxis:
ax.init3d()

def get_zaxis(self):
'''Return the ``ZAxis`` (`~.axis3d.Axis`) instance.'''
return self.zaxis

@cbook.deprecated("3.1", alternative="xaxis", pending=True)
@property
def w_xaxis(self):
return self.xaxis

@cbook.deprecated("3.1", alternative="yaxis", pending=True)
@property
def w_yaxis(self):
return self.yaxis

@cbook.deprecated("3.1", alternative="zaxis", pending=True)
@property
def w_zaxis(self):
return self.zaxis

def _get_axis_list(self):
return super()._get_axis_list() + (self.zaxis, )

Expand Down