Skip to content

tilted line visible in generated pdf file #5948

Closed

Description

@twmr
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import numpy as np

xr = np.linspace(-10, 10, 2)
X, Y = np.meshgrid(xr, xr)

# ncols needs to be >= 3 to trigger the problem
fig, axes = plt.subplots(nrows=1, ncols=3, sharey=True)

for iax, ax in enumerate(axes.flatten()):
    ax.set_aspect('equal')
    r = Rectangle((X.min(), Y.min()), X.ptp(), Y.ptp(),
                  color='k', fill=False, ls='--', lw=1)
    ax.add_patch(r)
    ax.set_xlim(X.min()-1, X.max()+1)
    ax.set_ylim(Y.min()-1, Y.max()+1)
plt.savefig('export.pdf')
plt.show()

When saving the above figure to a pdf file, an additional (unwanted) tilted dashed line is drawn on the third axis (=axes[2]). Note that this line is only visible in the generated pdf file and not in the interactive window.
mplpdfbug

Activity

  1. added this to the milestone on Jan 31, 2016
  2. tacaswell commented on Jan 31, 2016

    @tacaswell
    Member

    The other odd thing is that the x limits are not [-11, 11] like they should be set to...

  3. tacaswell commented on Jan 31, 2016

    @tacaswell
    Member

    and changing the figure size can suppress this issue as well.

  4. tacaswell commented on Jan 31, 2016

    @tacaswell
    Member

    It looks like this is an issue with the clipping, these are the paths for the rectangles from left to right (sorry about my silly variable names).

    In [7]: print(aardvark_0.decode('ascii'))
    -19.44385 58.909091 m
    -1 58.909091 m
    294.737968 58.909091 l
    294.737968 373.090909 l
    -1 373.090909 l
    
    
    In [8]: print(aardvark_1.decode('ascii'))
    138.109091 58.909091 m
    452.290909 58.909091 l
    452.290909 373.090909 l
    138.109091 373.090909 l
    138.109091 58.909091 l
    h
    
    
    In [9]: print(aardvark_2.decode('ascii'))
    295.662032 58.909091 m
    577 58.909091 l
    577 373.090909 m
    295.662032 373.090909 l
    295.662032 58.909091 l
    h
  5. tacaswell commented on Jan 31, 2016

    @tacaswell
    Member

    Ah, the problem is the trailing 'h' or the second 'm' in the last rectangle. Removing the h or changing the second m -> l fixes the problem.

  6. self-assigned this
    on Feb 1, 2016
  7. added a commit that references this issue on Feb 1, 2016
    a5e1ab4
  8. added a commit that references this issue on Feb 22, 2016
    1c690ee
  9. added a commit that references this issue on May 22, 2016
    befd75d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions