| 1 | xlim_changed not emitted on shared axis |
| 2 | <!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--> |
| 3 | <!--You can feel free to delete the sections that do not apply.--> |
| 4 | |
| 5 | ### Bug report |
| 6 | |
| 7 | **Bug summary** |
| 8 | |
| 9 | When an axis is shared with another its registered "xlim_changed" callbacks does not get called when the change is induced by a shared axis (via sharex=). |
| 10 | |
| 11 | In _base.py the set_xlim for sibling axis are called with emit=False: |
| 12 | |
| 13 | ``` |
| 14 | matplotlib/lib/matplotlib/axes/_base.py: |
| 15 | |
| 16 | /.../ |
| 17 | def set_xlim(...) |
| 18 | /.../ |
| 19 | if emit: |
| 20 | self.callbacks.process('xlim_changed', self) |
| 21 | # Call all of the other x-axes that are shared with this one |
| 22 | for other in self._shared_x_axes.get_siblings(self): |
| 23 | if other is not self: |
| 24 | other.set_xlim(self.viewLim.intervalx, |
| 25 | emit=False, auto=auto) |
| 26 | ``` |
| 27 | |
| 28 | I'm very new to matplotlib, so perhaps there is a good reason for this? emit=False seems to disable both continued "inheritance" of axis (why?) and triggering of change callbacks (looking at the code above). |
| 29 | |
| 30 | It seems like one would at least want to trigger the xlim_changed callbacks as they would be intended to react to any change in axis limits. |
| 31 | |
| 32 | Edit: Setting emit=True seems to introduce a recursion issue (not sure why but as inheritance seems to be passed along anyway it doesn't really matter). Moving the callback call to outside of the "if emit:"-statement seems to solve the issue as far as I can see when trying it out. Any reason to keep it inside the if-statement? |
| 33 | |