question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default color gradient directionality in displot

See original GitHub issue

The new displot function, when showing 2D histograms or KDE contours has its color gradient going from dark (few observations) to bright (many observations). To me this is confusing since many times the background is bright as well. In the absence of colorbar it is hard to figure out which of the bright squares has lots of observations and which has none. Consider this example (also note that the colorbar is wrong in the range of [0,1) ):

import seaborn as sns
sns.set(style="dark")
penguins = sns.load_dataset("penguins")
sns.displot(data=penguins, x="flipper_length_mm", y="culmen_length_mm", cbar=True)

Which results with: image The inner brighter squares contain lost of observations, as opposed to the bright bounding squares.

For a default I think that since Axes are filled by default with a bright color (either mpl default or seaborn-set color), it makes sense to vary colors by default from bright to dark. Also this is consistent with the way jointplot(kind="hex") works and the 2D kdeplots from version 0.10. But if current coloring is desired, perhaps make cbar=True the default?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mwaskomcommented, Aug 22, 2020

Seems that ggplot does a dark-to-light ramp, and thresholds, but the low end has no saturation and the top end has more: https://ggplot2.tidyverse.org/reference/geom_bin2d.html

0reactions
mwaskomcommented, Aug 22, 2020

Maybe consider using thresh=-np.inf as default? Matplotlib examples for hist2d usually color all pixels.

That would make it impossible to add a hue semantic (at least without changing another parameter).

Just doing a simple google image search suggests that there’s an approximately even split on whether 2D histograms do or do not include 0 counts in the color mapping. (And also that too many people are still using Jet).

Also worth pointing out that the problem specifically arises with style="dark", as the grid in style="darkgrid" will help to distinguish background from lighter extreme.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Choosing color palettes — seaborn 0.12.1 documentation
When seaborn needs a categorical palette with more colors than are available in the current default, it will use this approach. Using categorical...
Read more >
Annotate seaborn distplot with log scale throws an error
In a jupyter notebook with the inline backend the default option for showing figures is to run them through the bbox_inches="tight" option of ......
Read more >
plotly.figure_factory package — 5.11.0 documentation
color_continuous_midpoint (number (default None )) – If set, computes the bounds of the continuous color scale to have the desired midpoint. Setting this...
Read more >
Custom background color for your shinyapp - R-Project.org
Description. Allow to change the background color of your shiny application. ... Direction for gradient, by default to bottom . Possibles choices are...
Read more >
Chapter 4. Visualization with Matplotlib - O'Reilly
Matplotlib does a decent job of choosing default axes limits for your plot, ... Notice that the color argument is automatically mapped to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found