Skip to content
Snippets Groups Projects
Commit 2d717749 authored by Julian Lenz's avatar Julian Lenz
Browse files

Added specialized twinx(), twiny() methods to FancyAxes

parent d15ee203
No related branches found
No related tags found
No related merge requests found
......@@ -328,8 +328,45 @@ class FancyAxes(mpl.axes.Axes):
self.legend_ = Legend(self, handles, labels, **kwargs)
self.legend_._remove_method = self._remove_legend
return self.legend_
def twinx(self,fancy=True):
"""
This is identical to the original twinx() with the exception of the
'fancy' kwarg that will, per default, create a new FancyAxes instead
of a regular one.
"""
if fancy:
ax2 = self._make_twin_axes(sharex=self,projection='fancy')
else:
ax2 = self._make_twin_axes(sharex=self)
ax2.yaxis.tick_right()
ax2.yaxis.set_label_position('right')
ax2.yaxis.set_offset_position('right')
ax2.set_autoscalex_on(self.get_autoscalex_on())
self.yaxis.tick_left()
ax2.xaxis.set_visible(False)
ax2.patch.set_visible(False)
return ax2
def twiny(self,fancy=True):
"""
This is identical to the original twinx() with the exception of the
'fancy' kwarg that will, per default, create a new FancyAxes instead
of a regular one.
"""
if fancy:
ax2 = self._make_twin_axes(sharey=self,projection='fancy')
else:
ax2 = self._make_twin_axes(sharey=self)
ax2.xaxis.tick_top()
ax2.xaxis.set_label_position('top')
ax2.set_autoscaley_on(self.get_autoscaley_on())
self.xaxis.tick_bottom()
ax2.yaxis.set_visible(False)
ax2.patch.set_visible(False)
return ax2
# register the new Axes subclass as projection in matplotlib such that it can
# easily be chosen in add_subplot(), add_axes() etc. by specifying
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment