Add painter widget#7411
Conversation
|
I think this is going to have to also listen for re-size events to update the offsets if the window is resized. |
|
Done. I couldn't think of a way to preserve the selection while resizing, so it gets cleared. |
QuLogic
left a comment
There was a problem hiding this comment.
Mostly minor tweaks except maybe the transform question.
| @@ -0,0 +1,30 @@ | |||
| from __future__ import print_function | |||
There was a problem hiding this comment.
This can go after the docstring.
| @@ -0,0 +1,30 @@ | |||
| from __future__ import print_function | |||
| """ | |||
| Drag the mouse to paint selected areas of the plot. The callback prints | |||
There was a problem hiding this comment.
Can you add a title and such to match gallery stuff (see guidelines)?
|
|
||
|
|
||
| # Define the "on_select" callback. | ||
| def test(x, y): |
There was a problem hiding this comment.
Should have a more specific name.
| do_event(tool, 'onmove', xdata=110, ydata=110) | ||
| do_event(tool, 'release') | ||
|
|
||
| assert tool.overlay[tool.overlay == 2].size == 878 |
| self.canvas.draw_idle() | ||
|
|
||
|
|
||
| LABELS_CMAP = ListedColormap(['white', 'red', 'dodgerblue', 'gold', |
There was a problem hiding this comment.
Why these colours? Why can't we use an existing one?
There was a problem hiding this comment.
Where can I find an existing one?
| *cursor_props* : ditc | ||
| - The properties to apply to the cursor. | ||
| *radius* : int | ||
| - The radius of the cursor in pixels. |
There was a problem hiding this comment.
Unnecessary bullet point. Also, indent is only 3 spaces instead of 4.
| *cmap* : :class:~matplotlib.colorls.ListedColormap` | ||
| - The colormap to use for the cursors. | ||
| *useblit* : bool | ||
| - Whether to use blitting. |
There was a problem hiding this comment.
Unnecessary bullet point. Also, indent is only 3 spaces instead of 4.
| *radius* : int | ||
| - The radius of the cursor in pixels. | ||
| *cmap* : :class:~matplotlib.colorls.ListedColormap` | ||
| - The colormap to use for the cursors. |
There was a problem hiding this comment.
How are the alternate colours used? I can't get the example to trigger anything other than a red square.
| self._radius = r | ||
| xfm = self.ax.transData.inverted() | ||
| x0, y0 = xfm.transform((0, 0)) | ||
| x1, y1 = xfm.transform((r, r)) |
There was a problem hiding this comment.
I'm not totally sure this will work on a polar plot.
There was a problem hiding this comment.
Added a note that polar plots are not supported (to keep the implementation simpler).
| self._offsety = extents[1] | ||
| self._shape = (int(extents[3] - extents[1]), | ||
| int(extents[2] - extents[0])) | ||
| self._overlay = np.zeros(self._shape, dtype='uint8') |
There was a problem hiding this comment.
You may be able to use _image.resample in the same way that imshow eventually does if you want take a stab at preserving the overlay.
There was a problem hiding this comment.
That uses a lot of private APIs, I'd prefer to keep this simple. I added a note about the clearing behavior in the docs.
|
Thanks for the review, @QuLogic! I believe I had addressed all of your concerns. |
Current coverage is 62.06% (diff: 93.93%)
|
|
Is this something we still want for 3.0? Milestoning as such, but not because I think its a pressing need. Kinda cool though... |
|
Closing as too far out of date. |
|
If somebody is interested in this, starting as a 3rd-party-lib is a good way to accumulate user interest and stabilize the API. If both is done, we can reconsider integrating such a widget into core matplotlib later. |
Interestingly, my canvas only blacks out while licecap is running.