I’ve an EPS file named as f6mmP.eps
, which is slightly edited from this eps file by inkscape, as shown below:
Now, I want to embed the above EPS file in one of my Matplotlib figure and ensure that it remains in vector format in the final output. Based on the guidance/comment here and here, I figured out the following code snippet:
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
fig, ax = plt.subplots()
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
arr_lena = mpimg.imread('f6mmP.eps')
imagebox = OffsetImage(arr_lena, zoom=0.5)
ab = AnnotationBbox(imagebox, (0.8, 0.6))
ax.add_artist(ab)
plt.grid()
plt.draw()
plt.savefig("my_test.eps")
plt.show()
However, the EPS file embedded using the above method seems very blurred in the final result file, as shown below:
So, I want to know if I can embed an EPS/SVG in Matplotlib figure and ensure that they remain in vector format in the final output.
Regards,
HZ