Repository navigation
Conversation
|
|
||
| For the ruler to remain responsive you must keep a reference to it. | ||
|
|
||
| Parameters |
There was a problem hiding this comment.
When using numpydoc, you do not need to add markup to the parameter names (it is automatic) and can only use a limited number of heading names (see https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt)
| x0 = self.ax.get_xlim()[0] | ||
| y0 = self.ax.get_ylim()[0] | ||
|
|
||
| self.ruler, = self.ax.plot([x0, x0], [y0, y0], label='ruler', |
There was a problem hiding this comment.
Might not want to give it a label, this will make it appear in legends by default.
There was a problem hiding this comment.
I removed it. This is a leftover from when I attempted to use a legend to display the measure.
| # default marker props. Don't really want to override the entire props | ||
| # if a user only gives one value. | ||
|
|
||
| if markerprops is not None: |
There was a problem hiding this comment.
default_markerprops does not get re-used else where so you can do this is
used_markerprops = dict(...)
if markerprops is not None:
used_markerprops.update(markerprops)There was a problem hiding this comment.
Nice. This cleans it up a bit.
| else: | ||
| used_markerprops = default_markerprops | ||
|
|
||
| if textprops is not None: |
There was a problem hiding this comment.
Same comment as with markerprops above.
| self.axes_text = self.ax.annotate(s='', **used_textprops) | ||
| self.ax.add_artist(self.axes_text) | ||
|
|
||
| self.marker_a, = self.ax.plot((x0, y0), **used_markerprops) |
There was a problem hiding this comment.
These could all be one line as they all have the same marker, just use linestyle 'none'.
| string will be appended to the length text annotations. | ||
|
|
||
| """ | ||
| AxesWidget.__init__(self, ax) |
There was a problem hiding this comment.
How many of the inputs can be passed to the base-class init instead of dealing with them explicitly here?
| bbox=bbox) | ||
|
|
||
| x0 = self.ax.get_xlim()[0] | ||
| y0 = self.ax.get_ylim()[0] |
There was a problem hiding this comment.
I suggest initializing to np.nan.
| string will be appended to the length text annotations. | ||
|
|
||
| """ | ||
| AxesWidget.__init__(self, ax) |
There was a problem hiding this comment.
How many of the inputs can be passed to the base-class init instead of dealing with them explicitly here?
| self.marker_b, | ||
| self.marker_c] | ||
|
|
||
| def connect_events(self): |
There was a problem hiding this comment.
Should probably also listen for draw events to help with managing the blitting.
| self.marker_b, | ||
| self.marker_c] | ||
|
|
||
| def connect_events(self): |
There was a problem hiding this comment.
Should probably also listen for draw events to help with managing the blitting.
|
I left a bunch of comments, but over all 👍 Please take many of them as questions, if there is a reason you did something that I commented on, explain why you did it that way! This is not the simplest topic to take on as a first PR as anything involving blitting + user input has a large number of corner cases! |
|
Thanks for the feedback! When I get a chance I will implement/respond to
your comments. I kinda realized awhile ago that it might be a bit much for
my first PR. But if nothing else its a great challenge and learning
experience!
…On Sun, Jun 18, 2017 at 10:30 PM, Thomas A Caswell ***@***.*** > wrote:
I left a bunch of comments, but over all 👍 Please take many of them as
questions, if there is a reason you did something that I commented on,
explain why you did it that way!
This is not the simplest topic to take on as a first PR as anything
involving blitting + user input has a large number of corner cases!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#8774 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APvd_3zccXLsP5afb9eoCp5rVTF_YfU5ks5sFetGgaJpZM4N9heV>
.
|
|
I think a lot of attributes on the class could be made private. (Anything that's not private is going to become a backcompatibility nightmare at one point or another.) Also this needs some testing, see test_widgets.py. |
|
@anntzer Agreed. I will change as many as attributes as possible to private. Also thanks for the tip on test_widgets.py. I will write tests for it. |
|
@terranjp Any intetrest in still pushing this through? This looks well-written, and some care has gone into it. OTOH, I can see the use, but it seems very fiddly, and one ruler implimentation will suit some needs, but not be useful for other needs. I almost wonder if this should be made a tutorial example or a self-contained library? Edge-case tools like this may not belong in the core library? |
|
I think this should be a tutorial/third-party lib. |
|
@anntzer @jklymak I agree. I think it should be a third party library. It would be easier to make it a little less fiddly and easier for people to hack on it. I've been wanting to get back to it as I have some ideas I would implement and I would like to package it up correctly. A tutorial would also be helpful as it is not immediately apparent how to create something like this in matplotlib. I will try and devote some time to it. |
|
@terranjp OK, I'll close. If you end up with something that is rock solid that you think really has general benefit let us know. Note that there will be a toolbar manager at some point with extensible tools so a user could easily plug in a widget like this, rather than having it be something everyone has. Keep an eye out for it - I'm not sure how we will advertise non-native plugins, but ideally there will be a list of related projects somewhere. Thanks a lot for the contribution, and I hope you will consider adding other functionality! |
PR Summary
A ruler as described in issue #7216. It is heavily inspired by the ruler in ImageJ. This is my first PR to an open source project, and my first code that will be reviewed by others. I tried my best to adhere to the developer guide and the style the other widgets are written in. Feedback and constructive criticism would be much appreciated.
Issue #7216
PR Checklist
I could not find tests for the other widgets and I am not sure how to go about testing it. Help would be appreciated if this addition requires tests.
6