Skip to content

Vertices clipped for certain markers when plotting more than two points and saving as pdf #9829

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
nscottnichols opened this issue Nov 22, 2017 · 2 comments · Fixed by #17163
Assignees
Milestone

Comments

@nscottnichols
Copy link

Bug report

Bug summary
The vertices on certain markers ('^', 'D', 'v') are clipped when using plot() to plot data with more than two points and saving the plot as a PDF.

Code for reproduction

import matplotlib.pyplot as plt
size = 256, 16
fig,ax = plt.subplots()
num = 3

fig,ax = plt.subplots()
ax.plot([i+1 for i in range(num)],[1 for i in range(num)], '^', markersize=3, markeredgewidth=0.7, color='green', markeredgecolor='black')
ax.set_xlim(0, num +1)
ax.set_xticks(())
ax.set_yticks(())
fig.savefig('test.pdf') # This doesn't work properly.
fig.savefig('test.svg')

Actual outcome

pdfmarker
svgmarker

The top image is of the marker from the .pdf file. The bottom image is of the marker from the .svg file.

Expected outcome

The marker in the .pdf file should look like the marker in the .svg file.

Matplotlib version

  • Operating system: Ubuntu 17.04
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: Python 3.5.3
  • Jupyter version (if applicable):
  • Other libraries:

I installed matplotlib via pip.

@brunobeltran
Copy link
Contributor

#16719 has various details about why this is happening. I figured the discussion should remain on the older issue report, and closed my dup of it.

@QuLogic QuLogic self-assigned this Mar 12, 2020
@QuLogic
Copy link
Member

QuLogic commented Mar 12, 2020

The fix for #16719 is quite straightforward, but I need to a) write some tests and b) verify it works on the other marker types correctly.

QuLogic added a commit to QuLogic/matplotlib that referenced this issue Apr 17, 2020
The bbox only contains the points of the marker, but the line will
extend outside by half the line width. This was handled before, except
when the line is at an angle to the edge, as the edge is then wider than
half a line width. The maximum is at 45°, or √2.

This fixes corners on 'v', '^', '<', '>', 'p', 'h', 'H', 'D', 'd', 'X'.

Fixes matplotlib#9829.
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Apr 17, 2020
The bbox only contains the points of the marker, but the line will
extend outside by half the line width. This was handled before, except
when the line is at an angle to the edge, as then the line outside is
wider than half a line width. The maximum is at 45°, or √2.

This fixes corners on 'v', '^', '<', '>', 'p', 'h', 'H', 'D', 'd', 'X'.

Fixes matplotlib#9829.
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Apr 17, 2020
The bbox only contains the points of the marker, but the line will
extend outside by half the line width, unless it's mitered. The PDF
miter limit is 10, so pad by 5*line width (half the miter length).

This fixes corners on 'v', '^', '<', '>', 'p', 'h', 'H', 'D', 'd', 'X'.

Fixes matplotlib#9829.
anntzer pushed a commit to anntzer/matplotlib that referenced this issue Jun 9, 2020
The bbox only contains the points of the marker, but the line will
extend outside by half the line width, unless it's mitered. The PDF
miter limit is 10, so pad by 5*line width (half the miter length).

This fixes corners on 'v', '^', '<', '>', 'p', 'h', 'H', 'D', 'd', 'X'.

Fixes matplotlib#9829.
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Jun 10, 2020
The bbox only contains the points of the marker, but the line will
extend outside by half the line width, unless it's mitered. The PDF
miter limit is 10, so pad by 5*line width (half the miter length).

This fixes corners on 'v', '^', '<', '>', 'p', 'h', 'H', 'D', 'd', 'X'.

Fixes matplotlib#9829.
@QuLogic QuLogic modified the milestones: needs sorting, v3.3.0 Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants