Problem
I'm trying this demo of matplotlib.widgets.PolygonSelector widget: Select indices from a collection using polygon selector. The demo as is, is fine because the data is close to (0,0). However, if the data is not near the origin (e.g. add 500 to grid_x and grid_y in the demo) then the PolygonSelector cursor starts at (0,0) when the figure appears and the data is far off and appears small so I have to always zoom in before selecting points. It would be nice if the initial cursor position was relevant to the data.
Proposed solution
In the PolygonSelector widget init method replace:
self._xs, self._ys = [0], [0]
with
self._xs, self._ys = [sum(ax.get_xlim()) / 2], [sum(ax.get_ylim()) / 2
Then the cursor will be in the middle of the axes object that is past to the PolygonSelector initiator.
Problem
I'm trying this demo of matplotlib.widgets.PolygonSelector widget: Select indices from a collection using polygon selector. The demo as is, is fine because the data is close to (0,0). However, if the data is not near the origin (e.g. add 500 to grid_x and grid_y in the demo) then the PolygonSelector cursor starts at (0,0) when the figure appears and the data is far off and appears small so I have to always zoom in before selecting points. It would be nice if the initial cursor position was relevant to the data.
Proposed solution
In the PolygonSelector widget init method replace:
self._xs, self._ys = [0], [0]with
self._xs, self._ys = [sum(ax.get_xlim()) / 2], [sum(ax.get_ylim()) / 2Then the cursor will be in the middle of the axes object that is past to the PolygonSelector initiator.