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

Method twiny

lib/matplotlib/axes/_base.py:4885–4936  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

4883 return ax2
4884
4885 def twiny(self, axes_class=None, *, delta_zorder=0.0, **kwargs):
4886 """
4887 Create a twin Axes sharing the yaxis.
4888
4889 Create a new Axes with an invisible y-axis and an independent
4890 x-axis positioned opposite to the original one (i.e. at top). The
4891 y-axis autoscale setting will be inherited from the original Axes.
4892 To ensure that the tick marks of both x-axes align, see
4893 `~matplotlib.ticker.LinearLocator`.
4894
4895 Parameters
4896 ----------
4897 axes_class : subclass type of `~.axes.Axes`, optional
4898 The `.axes.Axes` subclass that is instantiated. This parameter
4899 is incompatible with *projection* and *polar*. See
4900 :ref:`axisartist_users-guide-index` for examples.
4901
4902 By default, `~.axes.Axes` is used.
4903
4904 .. versionadded:: 3.11
4905
4906 delta_zorder : float, default: 0
4907 A zorder offset for the twin Axes, relative to the original Axes.
4908 The twin's zorder is set to ``self.get_zorder() + delta_zorder``.
4909 By default (*delta_zorder* is 0), the twin has the same zorder as
4910 the original Axes.
4911
4912 kwargs : dict
4913 The keyword arguments passed to `.Figure.add_subplot` or `.Figure.add_axes`.
4914
4915 .. versionadded:: 3.11
4916
4917 Returns
4918 -------
4919 Axes
4920 The newly created Axes instance
4921
4922 Notes
4923 -----
4924 For those who are 'picking' artists while using twiny, pick
4925 events are only called for the artists in the top-most Axes.
4926 """
4927 if axes_class:
4928 kwargs["axes_class"] = axes_class
4929 ax2 = self._make_twin_axes(sharey=self, delta_zorder=delta_zorder, **kwargs)
4930 ax2.xaxis.tick_top()
4931 ax2.xaxis.set_label_position('top')
4932 ax2.set_autoscaley_on(self.get_autoscaley_on())
4933 self.xaxis.tick_bottom()
4934 ax2.yaxis.set_visible(False)
4935 ax2.yaxis.units = self.yaxis.units
4936 return ax2
4937
4938 @classmethod
4939 def get_shared_x_axes(cls):

Callers 13

twinyFunction · 0.45
test_twinx_claFunction · 0.45
test_twin_removeFunction · 0.45
_helper_yFunction · 0.45
test_titletwinyFunction · 0.45
test_titlesetposFunction · 0.45
test_xtick_rotation_modeFunction · 0.45

Calls 5

_make_twin_axesMethod · 0.95
tick_topMethod · 0.80
tick_bottomMethod · 0.80
set_label_positionMethod · 0.45
set_visibleMethod · 0.45

Tested by 12

test_twinx_claFunction · 0.36
test_twin_removeFunction · 0.36
_helper_yFunction · 0.36
test_titletwinyFunction · 0.36
test_titlesetposFunction · 0.36
test_xtick_rotation_modeFunction · 0.36