Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add painter widget #7411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed

Conversation

blink1073
Copy link
Member

@blink1073 blink1073 commented Nov 5, 2016

painter

Interestingly, my canvas only blacks out while licecap is running.

  • docs
  • example
  • tests

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Nov 6, 2016
@tacaswell
Copy link
Member

I think this is going to have to also listen for re-size events to update the offsets if the window is resized.

@blink1073
Copy link
Member Author

Done. I couldn't think of a way to preserve the selection while resizing, so it gets cleared.

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly minor tweaks except maybe the transform question.

@@ -0,0 +1,30 @@
from __future__ import print_function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a title and such to match gallery stuff (see guidelines)?



# Define the "on_select" callback.
def test(x, y):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these numbers mean?

@@ -2595,3 +2598,190 @@ def onmove(self, event):
self.canvas.blit(self.ax.bbox)
else:
self.canvas.draw_idle()


LABELS_CMAP = ListedColormap(['white', 'red', 'dodgerblue', 'gold',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these colours? Why can't we use an existing one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary bullet point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure this will work on a polar plot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@blink1073
Copy link
Member Author

Thanks for the review, @QuLogic! I believe I had addressed all of your concerns.

@codecov-io
Copy link

Current coverage is 62.06% (diff: 93.93%)

No coverage report found for master at 6709b59.

Powered by Codecov. Last update 6709b59...3e3d9bd

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Aug 29, 2017
@jklymak
Copy link
Member

jklymak commented May 2, 2018

Is this something we still want for 3.0? Milestoning as such, but not because I think its a pressing need. Kinda cool though...

@jklymak jklymak modified the milestones: needs sorting, v3.0 May 2, 2018
@jklymak jklymak modified the milestones: v3.0, needs sorting Jul 9, 2018
@jklymak jklymak marked this pull request as draft September 10, 2020 15:07
@blink1073
Copy link
Member Author

Closing as too far out of date.

@blink1073 blink1073 closed this Apr 9, 2022
@timhoffm
Copy link
Member

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.

@story645 story645 removed this from the future releases milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants