Open eloyvallinaes opened 4 months ago
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.
Oh here it is https://github.com/mwaskom/seaborn/issues/3601
Ah! You're right of course! 😄 Thanks!
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'
.