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

Skip to content

Fix minor bug in vertex insert #9396

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

Merged
merged 4 commits into from
Oct 21, 2017
Merged

Fix minor bug in vertex insert #9396

merged 4 commits into from
Oct 21, 2017

Conversation

fuzzythecat
Copy link
Contributor

  • If a vertex is inserted between the first and the second vertex, it is inserted at index 0, and the polygon automatically inserts a copy at the last index to keep the starting and ending points the same. It has an effect of inserting two vertices (one under the point, and the one previously at index 0), and the whole plot is messed up afterwards.

It is most evident when you have only two vertices on the plot.
figure_1

After an insert:
figure_2
figure_2-2

Ensuring no new vertex is inserted at index 0 fixes the problem.
After the fix:
figure_3

@anntzer
Copy link
Contributor

anntzer commented Oct 13, 2017

I think this could be made clearer by using np.insert(self.poly, [event.xdata, event.ydata], i, axis=0) (or i+1, haven't checked).
Likewise the deletion code just above could use np.delete.
Can you make these changes? If not it's also fine, this is already an improvement.

@fuzzythecat
Copy link
Contributor Author

Good point! I made the changes.

@dstansby dstansby added this to the v2.1.0-doc milestone Oct 18, 2017
@tacaswell
Copy link
Member

@fuzzythecat I took the liberty of adding a patch that fixes a nasty recursive draw in Qt (see discussion at #9406 ) and made the re-draw lazier.

Thanks for your work on making the docs better!

@tacaswell tacaswell merged commit 8b72f2b into matplotlib:master Oct 21, 2017
lumberbot-app bot pushed a commit that referenced this pull request Oct 21, 2017
tacaswell added a commit that referenced this pull request Oct 22, 2017
@fuzzythecat
Copy link
Contributor Author

🎉🎉

@fuzzythecat fuzzythecat deleted the patch-1 branch October 26, 2017 06:35
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.

4 participants