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

Plots using twinx draw on top of figure frame #2472

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
Oct 14, 2013
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
Fix #2472: Draw the spines on top of twin axes
  • Loading branch information
mdboom committed Oct 1, 2013
commit 6103f64fede1d8a393af6384d8404704e1eaafbb
7 changes: 4 additions & 3 deletions 7 lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8036,13 +8036,13 @@ def twinx(self):
For those who are 'picking' artists while using twinx, pick
events are only called for the artists in the top-most axes.
"""

ax2 = self._make_twin_axes(sharex=self, frameon=False)
ax2 = self._make_twin_axes(sharex=self)
ax2.yaxis.tick_right()
ax2.yaxis.set_label_position('right')
ax2.yaxis.set_offset_position('right')
self.yaxis.tick_left()
ax2.xaxis.set_visible(False)
ax2.patch.set_visible(False)
return ax2

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

ax2 = self._make_twin_axes(sharey=self, frameon=False)
ax2 = self._make_twin_axes(sharey=self)
ax2.xaxis.tick_top()
ax2.xaxis.set_label_position('top')
self.xaxis.tick_bottom()
ax2.yaxis.set_visible(False)
ax2.patch.set_visible(False)
return ax2

def get_shared_x_axes(self):
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions 21 lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,27 @@ def make_patch_spines_invisible(ax):
host.tick_params(axis='x', **tkw)


@image_comparison(baseline_images=['twin_spines_on_top'], extensions=['png'],
remove_text=True)
def test_twin_spines_on_top():
matplotlib.rcParams['axes.linewidth'] = 48.0
matplotlib.rcParams['lines.linewidth'] = 48.0

fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)

data = np.array([[1000, 1100, 1200, 1250],
[310, 301, 360, 400]])

ax2 = ax1.twinx()

ax1.plot(data[0], data[1]/1E3, color='#BEAED4')
ax1.fill_between(data[0], data[1]/1E3, color='#BEAED4', alpha=.8)

ax2.plot(data[0], data[1]/1E3, color='#7FC97F')
ax2.fill_between(data[0], data[1]/1E3, color='#7FC97F', alpha=.5)


@cleanup
def test_vline_limit():
fig = plt.figure()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.