Skip to content

tilted line visible in generated pdf file #5948

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
twmr opened this issue Jan 30, 2016 · 4 comments
Closed

tilted line visible in generated pdf file #5948

twmr opened this issue Jan 30, 2016 · 4 comments
Assignees
Milestone

Comments

@twmr
Copy link
Contributor

twmr commented Jan 30, 2016

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

@tacaswell tacaswell added this to the 1.5.2 (Critical bug fix release) milestone Jan 31, 2016
@tacaswell
Copy link
Member

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

@tacaswell
Copy link
Member

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

@tacaswell
Copy link
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

@tacaswell
Copy link
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.

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

3 participants