Skip to content

tilted line visible in generated pdf file #5948

Closed
@twmr

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions