Простой ответ: сохранить * .eps в растровый формат, как * .png
Длинный ответ: Однако, если Вам нравится масштабировать состоянии и theh способность изменять свойства внешнего вида, что-то, что сработало для меня, связано с импортом файла .svg с использованием библиотеки xml.dom. Вы можете использовать Inkscape для сохранения eps-файла в виде .svg.
Возьмите его на части и положить его обратно вместе в Matplotlib:
Это пример элемента SVG один может понадобиться перерисовывать:
<polygon id="SimpleShape" fill="none" stroke="#231F20" stroke-miterlimit="10" points="101.3,20.5 101.3,86.5 158.5,86.5 158.5,126.9 209.5,126.9 209.5,20.5 "/>
Во-первых, тянуть в SVG в виде списков вершин и свойства внешнего вида. Вы можете тянуть как мало или столько, сколько внешний вид атрибутов, как вы хотите:
from xml.dom import minidom
from matplotlib.path import Path
import matplotlib.patches as patches
doc = minidom.parse('path_to_svg_file.svg')
# pull the objects you want to re-plot into a dictionary
# in my case those were any polygons
gons = {}
for polygon in doc.getElementsByTagName('polygon'):
pts = polygon.getAttribute('points').split(' ')
label = polygon.getAttribute('id')
gons[label] = {}
gons[label]['pts'] = []
# build list of tuples for each point - [(x1,y1),(x2,y2)...(xn,yn)]
for pt in pts:
if len(pt) > 0:
gons[label]['pts'].append(tuple([float(val) for val in pt.split(',')]))
# close the path by appending the last point if you need to you could also
# get other information from the polygon such as color and line weight
gons[label]['pts'].append(gons[label][0])
# note the y value of a point must be inverted from inkscape*
gons[label]['pts'] = [(pt[0],-1*pt[1]) for pt in gons[label]['pts']]
Затем повторно построить путь в Matplotlib
for label in gons:
path = Path(gons[label]['pts']
patch = patches.PathPatch(path, facecolor=(0,0,0), lw=1)
ax.add_patch(patch)
Насколько я знаю, вы не можете «груз» ' eps' или 'pdf' в matplotlib и заново их заново – plonser