FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Python3 matplotlib 2.0.2 with Times New Roman misses unicode minus sign in pdf · Issue #9139 · matplotlib/matplotlib · GitHub

Repository navigation

Python3 matplotlib 2.0.2 with Times New Roman misses unicode minus sign in pdf #9139

Closed

Description

Bug report

With matplotlib 2.0.2 with python3.4.3, and "Times New Roman" font, saving figure as pdf file misses the unicode minus sign in the tick labels.

If I use pyplot.show() to directly show the figure, the figure is correct.

Also, only this particular combination of matplotlib and python version has this issue. I tried:

  • python2.7.6, matplotlib 2.0.2
  • python3.4.3, matplotlib 1.5.3

And they both work fine. Therefore I think it is not likely an issue with my environment, but rather a bug. But maybe I am missing something?

Code for reproduction

import matplotlib
from matplotlib import pyplot as plt

matplotlib.rcParams['font.family'] = 'Times New Roman'

plt.plot([-1, 0, 1], [-1, 0, 1])

# plt.show()
plt.savefig('draw.pdf')

Actual outcome

When I open the file using Adobe Acrobat Reader DC, it says

An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.

Matplotlib version

  • Operating System: Ubuntu 14.04.4
  • Matplotlib Version: 2.0.2
  • Python Version: 3.4.3
  • Jupyter Version (if applicable):
  • Other Libraries:

Executed in virtualenv. pip freeze output

cycler==0.10.0
matplotlib==2.0.2
numpy==1.13.1
pyparsing==2.2.0
python-dateutil==2.6.1
pytz==2017.2
six==1.10.0

If related, the LANG env var is set to "C". I also tried "en_US.UTF-8" and it didn't help.

Activity

  1. added this to the milestone on Sep 1, 2017
  2. tacaswell commented on Sep 1, 2017

    Member

    I wonder if this will be fixed by #9059 and this is an issue embedding the fonts?

  3. gaomy3832 commented on Sep 1, 2017

    Author

    Thanks for the reply.

    I have checked out and tried the current master head 751c9af. It does fix the minus sign issue, however the labels are now mistakenly in bold. I attach the two pdf files below. draw2.pdf is from python2 and draw3.pdf is from python3, with exactly the same code as included before. Is this an expected result?

    draw2.pdf
    draw3.pdf

  4. tacaswell commented on Sep 1, 2017

    Member

    No, they should be the same

  5. modified the milestones: , on Oct 9, 2017
  6. jsalort commented on Jan 11, 2018

    I have come into a problem which might be related to this issue.
    I seem to have a problem generating PDF files with Times LaTeX lowercase greek letters in labels. The plot shows fine on screen but the generated PDF is broken. If you think this is unrelated to the present issue, please tell me so that I open another issue.

    from matplotlib import RcParams
    import matplotlib.pyplot as plt
    
    latex_style_times = RcParams({'font.family': 'serif',
                   'font.serif': ['Times'],
                   'text.usetex': True,
                   })
    
    plt.style.use(latex_style_times)
    plt.figure()
    plt.plot([1, 2, 3], [1, 2, 3], 'o')
    plt.xlabel(r'$\delta\theta$')
    plt.ylabel(r'$\Delta\Theta$')
    plt.savefig('Essai.pdf')
    
    plt.show()

    Essai.pdf

    This also yields an error message in Adobe Acrobat Reader DC:

    Unable to extract incorporated font StandardSymL_Slant_167.

    I am running following versions:
    matplotlib.version == '2.1.1'
    python version == '3.6.4'

  7. modified the milestones: , on May 16, 2018
  8. modified the milestones: v3.0, v3.1 on Aug 11, 2018
  9. modified the milestones: v3.1.0, v2.2.5 on Mar 18, 2019
  10. modified the milestones: v2.2.5, v3.2.1 on Oct 22, 2019
  11. modified the milestones: v3.2.1, v3.2.2 on Mar 14, 2020
  12. modified the milestones: v3.2.2, v3.4.0 on Jun 12, 2020
  13. jkseppan commented on Jul 27, 2020

    Member

    @jsalort:

    I have come into a problem which might be related to this issue.
    I seem to have a problem generating PDF files with Times LaTeX lowercase greek letters in labels. The plot shows fine on screen but the generated PDF is broken. If you think this is unrelated to the present issue, please tell me so that I open another issue.
    [...]

    Unable to extract incorporated font StandardSymL_Slant_167.

    This is likely the same as #16087 which has a proposed fix in #18080.

  14. jkseppan commented on Jul 27, 2020

    Member

    The minus sign issue was probably fixed by #9059 and the boldface issue is something separate. I cannot reproduce it with current master, so please open a new issue if it is still happening.

  15. Qu246 commented on Apr 10, 2023

    Hi
    I am encountering a problem.
    Using Times New Roman font family, I cannot use \prime symbol anymore in my labels.
    I have understand that soe font family have issue with symbols susch as U+2032
    But how can I deal with this using Times New Roman ?
    Thanks

  16. oscargus commented on Apr 10, 2023

    Member

    @Qu246 The easiest way is probably just to use ' instead. If the symbol is not in the font, it is quite hard to something from Matplotlib's side (although we have a font fallback now, so if you supply several fonts it will select the first font that has the symbol).

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


      Back | FazBrowse Home | New Git URL