Flawed PDF save when using linewidth=0 in drawparallels() and drawmeridians()
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- matplotlib, python
调研方向
首先运行最小示例,并检查涉及 PDF 输出的 drawparallels() 和 drawmeridians() 入口点。在受影响的查看器中比较生成的 PDF,并确认使用 linewidth=0 不再产生错误的渲染,同时网格线仍保持隐藏。
由索引模型根据 Issue 内容生成。
描述
Hi all,
I noticed that when saving a basemap plot to a PDF file, the file is flawed when the code has
drawparallels(..., linewidth=0) or drawmerdians(..., linewidth=0) in it.
A minimal working example:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
figure=plt.figure(figsize=(14,7),dpi=100)
for ii in range(4):
axii=figure.add_subplot(2,2,ii+1)
m = Basemap(projection='cyl',
llcrnrlat=40,urcrnrlat=47,\
llcrnrlon=-72,urcrnrlon=-67,resolution='l',
ax=axii, fix_aspect=False)
m.drawcoastlines()
lat_ticks=np.arange(41, 47)
lon_ticks=np.arange(-72, -67)
m.drawparallels(lat_ticks,labels=[1,0,0,0],linewidth=0)
m.drawmeridians(lon_ticks,labels=[0,0,0,1],linewidth=0)
figure.savefig('test.pdf')
The PDF won't display correctly in some PDF viewers, for instance Xreader (v.2.4.4) or Adobe reader. But works fine in others, like Okular or Foxit reader. When compiling a LaTeX document using pdflatex, the page containing that figure won't display properly, again it is PDF viewer dependent.
Here is a screenshot of the PDF file opened in Xreader:

Here is the same file opened in Okular:

The reason for setting linewidth=0 is to remove those grid lines, one relevant questions on Stackoverflow.
One workaround I found is to use zorder=-2 to hide those grid lines while avoiding creating corrupted PDF files.
Note that I've tried a few different matplotlib backends, including Qt5Agg, TkAgg, Agg, and the results are all the same.
Some specs and package versions:
OS: Manjaro Linux
Python = 2.7 or 3.7, in an anaconda env
basemap = 1.2.0
matplotlib = 3.1.3 (for py3) and 1.2.0 (for py2)
- 主要语言
- Python
- 星标
- 817
- 派生
- 395
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
matplotlib/basemap 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
matplotlib/basemap#368 ·
-
难度 4/5 3-5 天 新手友好度 48/100
matplotlib/basemap#652 · 2 条评论 · 5 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 45/100
matplotlib/basemap#649 · 2 个 reaction ·
-
难度 5/5 一周以上 新手友好度 35/100
matplotlib/basemap#646 ·
-
难度 2/5 1-3 小时 新手友好度 48/100
matplotlib/basemap#645 · 2 条评论 ·
查看 matplotlib/basemap 的全部 Issue
相似的 Issue
-
documentation help wanted
难度 2/5 1-3 小时 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 90/100
simonw/sqlite-utils#872 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 78/100