Skip to content

BUG: PDF export seems wrong with dash sequences that include a None offset #8405

Closed

Description

@afvincent

Bug summary

Custom dash sequences of the form (None, on_off_seq) seem to be rendered as solid lines in PDF exports.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots(num="mwe")

linestyles = ('dashed', '--', (None, (3.7, 1.6)), (0, (3.7, 1.6)))
for y, ls in enumerate(linestyles):
    ax.plot([y]*2, ls=ls, label='{0}'.format(ls))

ax.set_ylim(-0.5, len(linestyles) - 0.5)  # useful on mpl < 2
ax.legend()

for ext in ('.png', '.pdf'):
    fig.savefig(fig.get_label() + ext)

Actual outcome
screenshot_of_mwe_v2 0 0
Please note that the picture above is a manual screenshot of the PDF produced with Matplotlib. For an unknown reason, GitHub does not allow me to upload the original PDF file…

Expected outcome
Something like the PNG export of the same plot:
mwe_v2 0 0

Both PNG and PDF look fine when exported with Matplotlib 1.5.1 (from conda). PDF export seems to be “broken” in this case both with Matplotlib 2.0.0 (from conda) and and master (from GitHub).

OS: CentOS 7
Python: 2.7

Activity

  1. added this to the milestone on Mar 30, 2017
  2. kahnchana commented on Apr 1, 2017

    @kahnchana
    Contributor

    What do you use for viewing pdfs? I got them same problem. However when the PDF is opened in chrome it showed up fine. Also for adobe reader 9 and edge it didn't even show the top two lines. Will go through this.

  3. afvincent commented on Apr 1, 2017

    @afvincent
    ContributorAuthor

    I have the issue with Evince, MuPDF, xpdf and qpdfview.

  4. tacaswell commented on Apr 2, 2017

    @tacaswell
    Member

    my guess is an overly agressive cut-out looking for None in the pdf backend.

  5. modified the milestones: , on May 3, 2017
  6. jkseppan commented on May 20, 2017

    @jkseppan
    Member

    It seems to me that the linestyle documentation specifies "(offset, on-off-dash-seq)" and only explains what the on-off-dash-seq can be. It doesn't really say what the type of the offset should be, but I don't see how it could be anything but a number, so the bug is that this generates invalid PDF output instead of erroring out.

  7. modified the milestones: , on Oct 9, 2017
  8. QuLogic commented on Mar 11, 2020

    @QuLogic
    Member

    Passing None is deprecated as of #15828, so I don't think we have any plans to fix this.

  9. modified the milestones: needs sorting, v3.3.0 on Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions