Issue
I have two polygons which are supposed to touch each other horizontally (no gap). However, when trying to plot them with PatchCollection, there seem to be a gap between the two, they are not touching:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.collections import PatchCollection
from matplotlib.patches import Polygon
fig, ax = plt.subplots()
points1 = [[ 0., 0.],
[10., 0.],
[10., 10.],
[ 0., 8.]]
points2 = [[10., 0.],
[10., 10.],
[20., 10.],
[18., 0.]]
pc = PatchCollection([Polygon(points1), Polygon(points2)])
ax.add_collection(pc)
ax.autoscale_view()
plt.show()
Is there any reason for that in my code, and can I fix it? Thank you.
Solution
The issue may be backend-specific as I can't reproduce it.
However, you are not alone, as there is a long-standing open issue on matplotlib.
A suggested solution is to set the edge color, i.e. in your case:
pc.set_edgecolor('face')
Answered By - Paul Brodersen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.