Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
Linewidth is treated differently for patches.Rectangle and lines.Line2D if exported to .svg, even with anti-aliasing turned on. This problem does not occur when exported to .png
Code for reproduction
importmatplotlibasmplimportmatplotlib.pyplotaspltimportmatplotlib.patchesaspatchesimportmatplotlib.linesaslinesmpl.rcParams['patch.antialiased']=Falsempl.rcParams['lines.antialiased']=Falsefig,ax=plt.subplots()l=lines.Line2D((0,0),(0,1),linewidth=2,color='k')ax.add_line(l)l=lines.Line2D((1,1),(0,1),linewidth=2,fillstyle='full')ax.add_line(l)p=patches.Rectangle((0,1),1,1,linewidth=2,fill=())ax.add_patch(p)magic_line=lines.Line2D((0,0.5),(1,1),linewidth=2,color='k',antialiased=False)ax.add_line(magic_line)ax.add_line(lines.Line2D((0.5,0.5),(0,0.9)))ax.set_xlim(-1,1.1)ax.set_ylim(-0.5,2.1)plt.savefig("problem.svg",dpi=900)
Actual outcome
The problematic area is where the overlay between the rectangle and the magic_line end (0.5,1) The issue in this troubleshooting example is slight and might need magnification to be seen, but becomes very noticable in cases of small figures exported to svg and scaled up afterwards,
By compiling it in .svg and .png we get different results, with what I think is antialiasing being applied differently even while being disabled and the same linewidth. This might also be two bugs in one.
**Expected outcome**The outcome should resemble the output for .png **Matplotlib version**<!--Please specify your platform and versions of the relevant libraries you are using:--> * Operating system: Win 10 * Matplotlib version: 2.1.2 * Matplotlib backend : module://ipykernel.pylab.backend_inline * Python version: 3.6.4 * Spyder version: 3.2.6 * Matplotlib installed from Anaconda with default settings<!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--><!--If you installed from conda, please specify which channel you used if not the default-->