@@ -3914,27 +3914,24 @@ def format_coord(self, x, y):
3914
3914
"""Return a format string formatting the *x*, *y* coordinates."""
3915
3915
twins = self ._twinned_axes .get_siblings (self )
3916
3916
if len (twins ) == 1 :
3917
- return "x={} y={} " .format (
3917
+ return "(x, y) = ({}, {}) " .format (
3918
3918
"???" if x is None else self .format_xdata (x ),
3919
3919
"???" if y is None else self .format_ydata (y ))
3920
- x_twins = []
3921
- y_twins = []
3920
+ screen_xy = self . transData . transform (( x , y ))
3921
+ xy_strs = []
3922
3922
# Retrieve twins in the order of self.figure.axes to sort tied zorders (which is
3923
3923
# the common case) by the order in which they are added to the figure.
3924
- for ax in self .figure .axes :
3925
- if ax in twins :
3926
- if ax is self or ax ._sharex is self or self ._sharex is ax :
3927
- x_twins .append (ax )
3928
- if ax is self or ax ._sharey is self or self ._sharey is ax :
3929
- y_twins .append (ax )
3930
- screen_xy = self .transData .transform ((x , y ))
3931
- return "x={} y={}" .format (
3932
- " | " .join (
3933
- ax .format_xdata (ax .transData .inverted ().transform (screen_xy )[0 ])
3934
- for ax in sorted (y_twins , key = attrgetter ("zorder" ))),
3935
- " | " .join (
3936
- ax .format_xdata (ax .transData .inverted ().transform (screen_xy )[1 ])
3937
- for ax in sorted (x_twins , key = attrgetter ("zorder" ))))
3924
+ for ax in sorted (
3925
+ [ax for ax in self .figure .axes if (
3926
+ ax in twins and (
3927
+ ax is self
3928
+ or ax ._sharex is self or self ._sharex is ax
3929
+ or ax ._sharey is self or self ._sharey is ax ))],
3930
+ key = attrgetter ("zorder" )):
3931
+ data_x , data_y = ax .transData .inverted ().transform (screen_xy )
3932
+ xy_strs .append (
3933
+ "({}, {})" .format (ax .format_xdata (data_x ), ax .format_ydata (data_y )))
3934
+ return "(x, y) = {}" .format (" | " .join (xy_strs ))
3938
3935
3939
3936
def minorticks_on (self ):
3940
3937
"""
0 commit comments