matplotlib generated PDF cannot be viewed in acrobat reader

后端 未结 1 1717
悲哀的现实
悲哀的现实 2021-01-06 06:44

I am plotting data with matplotlib including LaTeX fonts. The pdf created can be displayed by evince, inkscape, GIMP but not by acroread resp. adobe reader. The code prototy

相关标签:
1条回答
  • 2021-01-06 07:29

    After chasing my own bug in matplotlib I figured out based on this post and the referral the OP makes at matplotlib site that chasing bugs in matplotlib can be done with cairo. pip install cairo. Then on top of all other MPL imports add:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import ...
    
    import matplotlib
    matplotlib.use("cairo")
    
    from matplotlib.backends.backend_pdf import PdfPages
    ..etc.
    

    otherwise the chase will fail because the backend is already set and loaded....

    0 讨论(0)
提交回复
热议问题