问题
使用 matplotlib 生成的eps文件,不含hatch等,比如柱状的阴影等。
解决方案:
根据操作系统,找到 matplotlib 的安装目录下的backend_ps.py文件。以 Ubuntu 为例,文件路径为/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_ps.py
将 gsave
和 grestore
加入 self._pswriter.write
函数中:
# 加入前
""" % locals())
self._pswriter.write(
self._convert_path(Path.hatch(hatch), Affine2D().scale(sidelen),
simplify=False))
self._pswriter.write("""\
fill
stroke
} bind
>>
matrix
0.0 %(pageheight)f translate
makepattern
/%(name)s exch def
""" % locals())
# 加入后
""" % locals())
self._pswriter.write(
self._convert_path(Path.hatch(hatch), Affine2D().scale(sidelen),
simplify=False))
self._pswriter.write("""\
gsave #<<--------------------
fill
grestore #<<--------------------
stroke
} bind
>>
matrix
0.0 %(pageheight)f translate
makepattern
/%(name)s exch def
""" % locals())
GO-BACK UP-LEVEL TOP