I am trying to generate an svg file with Python and matplotlib. A simpler version of the code that I use is the following :
import matplotlib.pyplot as plt
plt.figure()
plt.fill([0,1,0.5],[0,0,1],color = "r")
plt.fill([1.5,1,0.5],[1,0,1],color = "b")
plt.show()
plt.savefig("soedgesvg.svg")
So far so good the result is as expected :
But when I open it in Inkscape I get an unexpected ghost edge with no color specified. This can be seen in the following picture :
Is there a way to remove this edge in Python before exporting the svg ?
This occurs only when a color is specified from my experience.
Inkscape 0.92.3 and matplotlib 3.1.1
The way to go is to add linewidth=0
when calling plt.fill
like so :
plt.fill([0,1,0.5],[0,0,1],color = "r", linewidth=0)
plt.fill([1.5,1,0.5],[1,0,1],color = "b", linewidth=0)
This answer has been provided by @ImportanceOfBeingErnest in the comments with the following explanation :
Because the linewidth is defined in points. When you zoom inside matplotlib, the lines always keep their physical size, e.g. 1/72. of an inch. When you zoom in in Inkscape you zoom into the actual figure, up to the point where maybe your screen only shows 1/72. of an inch and hence the line will be as large as the screen.