Skip to content

log_scale parameter for displot() is a bit misleading. #3931

Description

@anordin95

The relevant documentation for the log_scale parameter is: "Set axis scale(s) to log. A single value sets the data axis for any numeric axes in the plot. A pair of values sets each axis independently.".

From that description, it seems reasonable to expect log_scale = (False, True) to apply a log-scaling only to the y-axis for a univariate histogram. In practice, you get a blank plot. I imagine this setting should really only be used for two dimensional histograms, that is, the computed count variable is the third dimension.

Below is a simple example illustrating where I got confused. I'd have expected the first plotting call to produce a plot with log-scaled counts on the y-axis, instead, nothing appears. I think it makes sense to tweak the documentation & perhaps also provide a warning to a user who doesn't specify an argument for the y parameter, but still attempts to provide a tuple to log_scale.

Image
import seaborn as sns
import numpy as np
# Apply the default seaborn plotting theme.
sns.set_theme()

data = np.repeat(['a','b','c'], [200, 100, 10])

sns.displot(data, height=3, log_scale=(False, True))
sns.displot(data, height=3, log_scale=(False, False))

PS: I'm happy to also take a stab at fixing the issue, just thought it'd be a good idea to writeup the issue first.

PPS: I'm a huge fan of this library. Thank you for the excellent work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions