-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for faceted plots with plt.hexbin and plt.hist2d #321
Comments
The one thing I would wonder about is that it would surrender control over colors to the axis color cycles. That might produce some surprising results, and currently when you map multiple kinds of plots they have the same color, which I think would no longer be the case. I'm also not sure if that will break
That feels messy, I think I would want to resist this as much as possible. The second solution seems a lot more workable and I agree more broadly useful (the default parameters for
This feels similarly messy in terms of hardcoding assumptions about certain plot functions. I'd like to keep
Ah, yes...
👍 |
Hi, has there been any developement on this? I've been running into the same issues. Is there a preferred workaround other than the fix described above? |
With #2125: g = sns.FacetGrid(penguins, col="species", hue="species")
g.map_dataframe(sns.histplot, x="culmen_length_mm", y="culmen_depth_mm")
g.set_axis_labels("Culmen length", "Culmen depth") It doesn't do hexbin. I think that will be a different (new) function. |
Gorgeous! Nice work @mwaskom ! |
Also should note: that plot will soon be easier to make by doing something like sns.distplot(
data=penguins, x="culmen_length_mm", y="culmen_depth_mm",
hue="species", col="species",
) But that remains to be implemented. |
Just to add two more items to my seaborn wish-list: It would great if
FacetGrid
andPairGrid
worked well with hexbin and/or hist2d plots.Hexbin
plt.hexbin
works, but the defaults are so bad that you can barely tell:Notice that by default
edgecolor
is controlled by thehue
argument, which looks rather strange.Tweaking some options makes a big difference (also solves the aesthetic issues in #271):
Hist2D
Nope!
The culprit (also for the inability to control edgecolor with hexbin) is this line:
https://github.com/mwaskom/seaborn/blob/v0.4.0/seaborn/axisgrid.py#L418
If we move that statement inside the conditional on the next line (
if self._hue_var is not None
), then that solves the color issues withhexbin
and I can gethist2d
working. Again, the defaults are terrible:When tweaked, it looks OK:
(Yes, matplotlib uses totally different keyword arguments in
hexbin
andhist2d
for all the control nobs, even if they are basically equivalent.)Action items
FacetGrid.map
? Perhaps the clearer solution is to writesns.binplot
(mirroringsns.kdeplot
) to provide a unified API with better defaults, which we could also use insns.jointplot
?range
/extent
argument for all these plots together based on the shared x and y limits.The text was updated successfully, but these errors were encountered: