8000 Error in PDF backend, extra clipbox crops markers slightly · Issue #16719 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
8000

Error in PDF backend, extra clipbox crops markers slightly #16719

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
brunobeltran opened this issue Mar 10, 2020 · 1 comment
Closed

Error in PDF backend, extra clipbox crops markers slightly #16719

brunobeltran opened this issue Mar 10, 2020 · 1 comment

Comments

@brunobeltran
Copy link
Contributor

Bug report

Bug summary

The PDF backend has different behavior than the rest of the backends when drawing "MarkerStyle" objects. It puts each marker into a group with a clip-path (a unit box in the local coordinates of the marker path, it seems like?)

This bug was likely not caught before because it looks like backend_pdf is just forcing _joinstyle='bevel' (which would still be inconsistent, but looks rather nice). This is not what's happening though, see below.

No other backends appear to be affected. Error seems to be in the code that handles rendering lines specifically (lone markers not affected).

Code for reproduction

This is fine

plt.plot(0,0, c='k', marker='X', markersize=50, markeredgewidth=10,
             fillstyle='full', markerfacecolor='white', linestyle='-', lw=3, clip_on=False)
plt.gca().axis('off')
plt.savefig('/tmp/test.pdf')
plt.savefig('/tmp/test.svg')
plt.savefig('/tmp/test.ps')
plt.savefig('/tmp/test.png') # using backend_agg on my computer

But this is "clipped"

plt.plot([0,1], [0,1], c='k', marker='X', markersize=50, markeredgewidth=10,
             fillstyle='full', markerfacecolor='white', linestyle='-', lw=3, clip_on=False)
plt.gca().axis('off')
plt.savefig('/tmp/test.pdf')
plt.savefig('/tmp/test.svg')
plt.savefig('/tmp/test.ps')
plt.savefig('/tmp/test.png') # using backend_agg on my computer

Actual outcome

The single marker looks the same in all files.
test-fig-4

Whereas the markers on lines look different (notice the bevel'd edges below) in the PDF:
test-fig-4 pdf

vs the PNG:
test-fig-4

All PDF viewers that I have seem to agree the beveled edges should be there.

When Inkscape converts it to SVG, it has the following structure:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
...
  <defs
     id="defs51">
    <clipPath
       id="clip1">
      <path
         id="path45"
         d="M 39.21875 212.117188 L 99.21875 212.117188 L 99.21875 272.117188 L 39.21875 272.117188 Z M 39.21875 212.117188 " />
    </clipPath>
    <clipPath
      ...other marker's clipPath, similar
    </clipPath>
  </defs>

  <g
     id="surface966">
    <rect
       ...axis />
    <path
       ... line/>
    <g
       id="g61"
       clip-rule="nonzero"
       clip-path="url(#clip1)">
      <path
         id="path59"
         transform="matrix(1,0,0,-1,69.218182,242.116364)"
         d="M -12.499432 -25.000824 L 0.000568182 -12.500824 L 12.500568 -25.000824 L 25.000568 -12.500824 L 12.500568 -0.000823864 L 25.000568 12.499176 L 12.500568 24.999176 L 0.000568182 12.499176 L -12.499432 24.999176 L -24.999432 12.499176 L -12.499432 -0.000823864 L -24.999432 -12.500824 Z M -12.499432 -25.000824 "
         style="fill:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" />
    </g>
   ...
    <g
      ... other marker, similar />
    </g>
  </g>
</svg>

Expected outcome

They should all be the same.

Matplotlib version

  • Operating system: Debian 9
  • Matplotlib version: 3.1.3
  • Matplotlib backend (print(matplotlib.get_backend())): see above
  • Python version: 3.7.3
  • Jupyter version (if applicable): N/A
  • Other libraries: N/A
@brunobeltran
Copy link
Contributor Author

Closing as dup of #9829.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0