MCPcopy Index your code
hub / github.com/pydata/xarray / _update_axes

Function _update_axes

xarray/plot/utils.py:786–832  ·  view source on GitHub ↗

Update axes with provided parameters

(
    ax: Axes,
    xincrease: bool | None,
    yincrease: bool | None,
    xscale: ScaleOptions = None,
    yscale: ScaleOptions = None,
    xticks: ArrayLike | None = None,
    yticks: ArrayLike | None = None,
    xlim: tuple[float, float] | None = None,
    ylim: tuple[float, float] | None = None,
)

Source from the content-addressed store, hash-verified

784
785
786def _update_axes(
787 ax: Axes,
788 xincrease: bool | None,
789 yincrease: bool | None,
790 xscale: ScaleOptions = None,
791 yscale: ScaleOptions = None,
792 xticks: ArrayLike | None = None,
793 yticks: ArrayLike | None = None,
794 xlim: tuple[float, float] | None = None,
795 ylim: tuple[float, float] | None = None,
796) -> None:
797 """
798 Update axes with provided parameters
799 """
800 if xincrease is None:
801 pass
802 elif (xincrease and ax.xaxis_inverted()) or (
803 not xincrease and not ax.xaxis_inverted()
804 ):
805 ax.invert_xaxis()
806
807 if yincrease is None:
808 pass
809 elif (yincrease and ax.yaxis_inverted()) or (
810 not yincrease and not ax.yaxis_inverted()
811 ):
812 ax.invert_yaxis()
813
814 # The default xscale, yscale needs to be None.
815 # If we set a scale it resets the axes formatters,
816 # This means that set_xscale('linear') on a datetime axis
817 # will remove the date labels. So only set the scale when explicitly
818 # asked to. https://github.com/matplotlib/matplotlib/issues/8740
819 if xscale is not None:
820 ax.set_xscale(xscale)
821 if yscale is not None:
822 ax.set_yscale(yscale)
823
824 if xticks is not None:
825 ax.set_xticks(xticks)
826 if yticks is not None:
827 ax.set_yticks(yticks)
828
829 if xlim is not None:
830 ax.set_xlim(xlim)
831 if ylim is not None:
832 ax.set_ylim(ylim)
833
834
835def _is_monotonic(coord, axis=0):

Callers 3

lineFunction · 0.90
histFunction · 0.90
newplotfuncFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…