Description
Problem
I tried to post this on discourse, but that forum is too restrictive in flagging my question as spam (just because I am linking to the specific lines of code to provide context).. so here goes:
it used to be that Axes.get_shared_x_axes()
returned a cbook.Grouper()
which had a .join()
method, but now it is returning an cbook.GrouperView()
that is IMMUTABLE. It is breaking my tool and I don't even understand the rationale for such backward incompatible change.
regardless, I need a workaround that would continue to work with future versions of matplotlib. Much appreciate your help in pointing me to the right methods and properties to achieve the same effect as this.
thanks very much.
Proposed solution
revert to the previous behaviour of Axes.get_shared_x_axes()
returning a mutable Grouper
Activity
[-][ENH]: [/-][+][ENH]: Axes.get_shared_x_axes() returning mutable Grouper[/+]jklymak commentedon Oct 21, 2023
I think you want https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.sharex.html
ksunden commentedon Oct 21, 2023
This was deprecated in 3.6.0 in #21584 and should have been warning for several releases now.
https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.6.0.html#groupers-from-get-shared-x-axes-get-shared-y-axes-will-be-immutable
Calling
sharex
is the expected api for doing this task, and additionally makes sure that the axes are consistent when sharing is started (though fundementally it is doing the same thing to the underlying Grouper object).