MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / twinx

Method twinx

lib/matplotlib/axes/_base.py:4831–4883  ·  view source on GitHub ↗

Create a twin Axes sharing the xaxis. Create a new Axes with an invisible x-axis and an independent y-axis positioned opposite to the original one (i.e. at right). The x-axis autoscale setting will be inherited from the original Axes. To ensure that the tic

(self, axes_class=None, *, delta_zorder=0.0, **kwargs)

Source from the content-addressed store, hash-verified

4829 return twin
4830
4831 def twinx(self, axes_class=None, *, delta_zorder=0.0, **kwargs):
4832 """
4833 Create a twin Axes sharing the xaxis.
4834
4835 Create a new Axes with an invisible x-axis and an independent
4836 y-axis positioned opposite to the original one (i.e. at right). The
4837 x-axis autoscale setting will be inherited from the original
4838 Axes. To ensure that the tick marks of both y-axes align, see
4839 `~matplotlib.ticker.LinearLocator`.
4840
4841 Parameters
4842 ----------
4843 axes_class : subclass type of `~.axes.Axes`, optional
4844 The `.axes.Axes` subclass that is instantiated. This parameter
4845 is incompatible with *projection* and *polar*. See
4846 :ref:`axisartist_users-guide-index` for examples.
4847
4848 By default, `~.axes.Axes` is used.
4849
4850 .. versionadded:: 3.11
4851
4852 delta_zorder : float, default: 0
4853 A zorder offset for the twin Axes, relative to the original Axes.
4854 The twin's zorder is set to ``self.get_zorder() + delta_zorder``.
4855 By default (*delta_zorder* is 0), the twin has the same zorder as
4856 the original Axes.
4857
4858 kwargs : dict
4859 The keyword arguments passed to `.Figure.add_subplot` or `.Figure.add_axes`.
4860
4861 .. versionadded:: 3.11
4862
4863 Returns
4864 -------
4865 Axes
4866 The newly created Axes instance
4867
4868 Notes
4869 -----
4870 For those who are 'picking' artists while using twinx, pick
4871 events are only called for the artists in the top-most Axes.
4872 """
4873 if axes_class:
4874 kwargs["axes_class"] = axes_class
4875 ax2 = self._make_twin_axes(sharex=self, delta_zorder=delta_zorder, **kwargs)
4876 ax2.yaxis.tick_right()
4877 ax2.yaxis.set_label_position('right')
4878 ax2.yaxis.set_offset_position('right')
4879 ax2.set_autoscalex_on(self.get_autoscalex_on())
4880 self.yaxis.tick_left()
4881 ax2.xaxis.set_visible(False)
4882 ax2.xaxis.units = self.xaxis.units
4883 return ax2
4884
4885 def twiny(self, axes_class=None, *, delta_zorder=0.0, **kwargs):
4886 """

Callers 15

run_memleak_testFunction · 0.45
twinxFunction · 0.45
test_span_selectorFunction · 0.45
test_gidFunction · 0.45
test_parasiteMethod · 0.45
test_twinx_claFunction · 0.45
test_twinx_axis_scalesFunction · 0.45
test_subplot_key_hashFunction · 0.45

Calls 6

_make_twin_axesMethod · 0.95
tick_rightMethod · 0.80
set_offset_positionMethod · 0.80
tick_leftMethod · 0.80
set_label_positionMethod · 0.45
set_visibleMethod · 0.45

Tested by 15

test_span_selectorFunction · 0.36
test_gidFunction · 0.36
test_parasiteMethod · 0.36
test_twinx_claFunction · 0.36
test_twinx_axis_scalesFunction · 0.36
test_subplot_key_hashFunction · 0.36
test_twin_removeFunction · 0.36
test_twin_spinesFunction · 0.36