Skip to content

Fix minor bug in vertex insert - #9396

Merged
tacaswell merged 4 commits into
matplotlib:masterfrom
fuzzythecat:patch-1
Oct 21, 2017
Merged

tacaswell merged 4 commits into
matplotlib:masterfrom
fuzzythecat:patch-1

Conversation

@fuzzythecat

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

anntzer commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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