You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working with sns.scatterplot for representing locations on a grid, I discovered an issue where using hue and hue_order produces an incorrect plot: markers that should be perfectly overlapping—they have identical (x, y) coordinates—are drawn at a small offset, such that the edge of one can be seen intersecting the other. Here's a minimal example that reproduces the issue with matplotlib 3.9.1 and seaborn 0.13.2:
That code produces the following plot:
where at each corner, the edge of the second marker is clearly seen to intersect the face of the first
From my brief dive into this problem:
As in the example, it doesn't matter whether a tall stack of markers are made to overlap: there's only to points with the exact (6.3, -12.42) coordinates and the problem is there.
The issue is seaborn-specific. Using matplotlib's plt.scatter does yield a correct plot.
Both hue and hue_order need to be used in order for the issue to appear. Slicing the data with df[df.locid == 'loc1'] makes a correct plot.
The problem persists even with marker='.' , marker='s', marker='v' and marker='d', but not with marker='x'.
The text was updated successfully, but these errors were encountered:
I don't think anything is wrong with the position things are plotted in here. Rather, using hue_order in scatteplot doesn't suppress the datapoints from the plot, but it does cause the facecolor to be null. So you're seeing the edges from the loc2 points. I could have sworn there was an issue about this already but couldn't find it quickly.
I took a look at relational._ScatterPlotter.plot and thought some logic could be added to fix this problem, so here's a pull request #3730. I assumed the intended behaviour is to have transparent edges whenever hue_order has made a face transparent, while preserving whatever edgecolor (white is default) was passed to the plot method.
It's a bit of a patch but it covers all the use cases I could think of.
While working with
sns.scatterplot
for representing locations on a grid, I discovered an issue where usinghue
andhue_order
produces an incorrect plot: markers that should be perfectly overlapping—they have identical (x
,y
) coordinates—are drawn at a small offset, such that the edge of one can be seen intersecting the other. Here's a minimal example that reproduces the issue withmatplotlib 3.9.1
andseaborn 0.13.2
:That code produces the following plot:
where at each corner, the edge of the second marker is clearly seen to intersect the face of the first
From my brief dive into this problem:
plt.scatter
does yield a correct plot.hue
andhue_order
need to be used in order for the issue to appear. Slicing the data withdf[df.locid == 'loc1']
makes a correct plot.marker='.'
,marker='s'
,marker='v'
andmarker='d'
, but not withmarker='x'
.The text was updated successfully, but these errors were encountered: