Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf7521c

Browse files
committed
fix y axis on 3d plot
This commit corrects the axis which the 3D y axis inherits from. The y-axis on 3D plots initially inherited from the x axis object, rather than a y axis object. This resulted in a bug where the x axis (instead of the y) was inverted for 3D plots when was called. After inheritance correction, correct behavior was achieved with inversion, but the tick marks were incorrectly placed. The default location for tick marks on the y-axis is now set to be right, rather than left. Resolves matplotlib#21369
1 parent a7bb7b0 commit cf7521c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ def __init__(
130130
self.set_axis_on()
131131
self.M = None
132132

133+
# Change the y-axis ticks to be on the right side
134+
self.yaxis.set_ticks_position("right")
135+
133136
# func used to format z -- fall back on major formatters
134137
self.fmt_zdata = None
135138

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def tick_update_position(tick, tickxs, tickys, labelpos):
3232
tick.gridline.set_data(0, 0)
3333

3434

35-
class Axis(maxis.XAxis):
35+
class Axis(maxis.Axis):
3636
"""An Axis class for the 3D plots."""
3737
# These points from the unit cube make up the x, y and z-planes
3838
_PLANES = (
@@ -516,21 +516,21 @@ def v_interval(self, minmax):
516516
# Use classes to look at different data limits
517517

518518

519-
class XAxis(Axis):
519+
class XAxis(Axis, maxis.XAxis):
520520
get_view_interval, set_view_interval = maxis._make_getset_interval(
521521
"view", "xy_viewLim", "intervalx")
522522
get_data_interval, set_data_interval = maxis._make_getset_interval(
523523
"data", "xy_dataLim", "intervalx")
524524

525525

526-
class YAxis(Axis):
526+
class YAxis(Axis, maxis.YAxis):
527527
get_view_interval, set_view_interval = maxis._make_getset_interval(
528528
"view", "xy_viewLim", "intervaly")
529529
get_data_interval, set_data_interval = maxis._make_getset_interval(
530530
"data", "xy_dataLim", "intervaly")
531531

532532

533-
class ZAxis(Axis):
533+
class ZAxis(Axis, maxis.XAxis):
534534
get_view_interval, set_view_interval = maxis._make_getset_interval(
535535
"view", "zz_viewLim", "intervalx")
536536
get_data_interval, set_data_interval = maxis._make_getset_interval(

0 commit comments

Comments
 (0)