@@ -3977,27 +3977,24 @@ def format_coord(self, x, y):
3977
3977
"""Return a format string formatting the *x*, *y* coordinates."""
3978
3978
twins = self ._twinned_axes .get_siblings (self )
3979
3979
if len (twins ) == 1 :
3980
- return "x={} y={} " .format (
3980
+ return "(x, y) = ({}, {}) " .format (
3981
3981
"???" if x is None else self .format_xdata (x ),
3982
3982
"???" if y is None else self .format_ydata (y ))
3983
- x_twins = []
3984
- y_twins = []
3983
+ screen_xy = self . transData . transform (( x , y ))
3984
+ xy_strs = []
3985
3985
# Retrieve twins in the order of self.figure.axes to sort tied zorders (which is
3986
3986
# the common case) by the order in which they are added to the figure.
3987
- for ax in self .figure .axes :
3988
- if ax in twins :
3989
- if ax is self or ax ._sharex is self or self ._sharex is ax :
3990
- x_twins .append (ax )
3991
- if ax is self or ax ._sharey is self or self ._sharey is ax :
3992
- y_twins .append (ax )
3993
- screen_xy = self .transData .transform ((x , y ))
3994
- return "x={} y={}" .format (
3995
- " | " .join (
3996
- ax .format_xdata (ax .transData .inverted ().transform (screen_xy )[0 ])
3997
- for ax in sorted (y_twins , key = attrgetter ("zorder" ))),
3998
- " | " .join (
3999
- ax .format_xdata (ax .transData .inverted ().transform (screen_xy )[1 ])
4000
- for ax in sorted (x_twins , key = attrgetter ("zorder" ))))
3987
+ for ax in sorted (
3988
+ [ax for ax in self .figure .axes if (
3989
+ ax in twins and (
3990
+ ax is self
3991
+ or ax ._sharex is self or self ._sharex is ax
3992
+ or ax ._sharey is self or self ._sharey is ax ))],
3993
+ key = attrgetter ("zorder" )):
3994
+ data_x , data_y = ax .transData .inverted ().transform (screen_xy )
3995
+ xy_strs .append (
3996
+ "({}, {})" .format (ax .format_xdata (data_x ), ax .format_ydata (data_y )))
3997
+ return "(x, y) = {}" .format (" | " .join (xy_strs ))
4001
3998
4002
3999
def minorticks_on (self ):
4003
4000
"""
0 commit comments