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 95cfcae

Browse filesBrowse files
committed
Merge pull request #2472 from mdboom/twin-spines-on-top
Plots using twinx draw on top of figure frame
2 parents 30e37eb + 6103f64 commit 95cfcae
Copy full SHA for 95cfcae

File tree

Expand file treeCollapse file tree

3 files changed

+25
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-3
lines changed

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8036,13 +8036,13 @@ def twinx(self):
80368036
For those who are 'picking' artists while using twinx, pick
80378037
events are only called for the artists in the top-most axes.
80388038
"""
8039-
8040-
ax2 = self._make_twin_axes(sharex=self, frameon=False)
8039+
ax2 = self._make_twin_axes(sharex=self)
80418040
ax2.yaxis.tick_right()
80428041
ax2.yaxis.set_label_position('right')
80438042
ax2.yaxis.set_offset_position('right')
80448043
self.yaxis.tick_left()
80458044
ax2.xaxis.set_visible(False)
8045+
ax2.patch.set_visible(False)
80468046
return ax2
80478047

80488048
def twiny(self):
@@ -8061,11 +8061,12 @@ def twiny(self):
80618061
events are only called for the artists in the top-most axes.
80628062
"""
80638063

8064-
ax2 = self._make_twin_axes(sharey=self, frameon=False)
8064+
ax2 = self._make_twin_axes(sharey=self)
80658065
ax2.xaxis.tick_top()
80668066
ax2.xaxis.set_label_position('top')
80678067
self.xaxis.tick_bottom()
80688068
ax2.yaxis.set_visible(False)
8069+
ax2.patch.set_visible(False)
80698070
return ax2
80708071

80718072
def get_shared_x_axes(self):
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,27 @@ def make_patch_spines_invisible(ax):
16461646
host.tick_params(axis='x', **tkw)
16471647

16481648

1649+
@image_comparison(baseline_images=['twin_spines_on_top'], extensions=['png'],
1650+
remove_text=True)
1651+
def test_twin_spines_on_top():
1652+
matplotlib.rcParams['axes.linewidth'] = 48.0
1653+
matplotlib.rcParams['lines.linewidth'] = 48.0
1654+
1655+
fig = plt.figure()
1656+
ax1 = fig.add_subplot(1, 1, 1)
1657+
1658+
data = np.array([[1000, 1100, 1200, 1250],
1659+
[310, 301, 360, 400]])
1660+
1661+
ax2 = ax1.twinx()
1662+
1663+
ax1.plot(data[0], data[1]/1E3, color='#BEAED4')
1664+
ax1.fill_between(data[0], data[1]/1E3, color='#BEAED4', alpha=.8)
1665+
1666+
ax2.plot(data[0], data[1]/1E3, color='#7FC97F')
1667+
ax2.fill_between(data[0], data[1]/1E3, color='#7FC97F', alpha=.5)
1668+
1669+
16491670
@cleanup
16501671
def test_vline_limit():
16511672
fig = plt.figure()

0 commit comments

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