Skip to content
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

scatter plot with wide data: markers=False gives an error #3652

Open
jhncls opened this issue Mar 10, 2024 · 3 comments
Open

scatter plot with wide data: markers=False gives an error #3652

jhncls opened this issue Mar 10, 2024 · 3 comments

Comments

@jhncls
Copy link

jhncls commented Mar 10, 2024

Seaborn 0.13 is getting more friendly towards wide form data. With a scatter plot, the index (if available) is used as x=, and the columns are used both as hue= and style=. If the user wants to remove the effects of style, markers=False gives an error : "KeyError: 'marker'".

Code tested with seaborn 0.13.2 and also the latest dev version:

flights_wide = sns.load_dataset('flights').pivot(index='year', columns='month', values='passengers')
sns.scatterplot(data=flights_wide, markers=False)

With markers=['.'], there is a warning about not having enough markers. (The more convoluted markers=['.']*len(flights_wide.columns) works without problem.)

On the other hand, marker='.' is completely ignored.

PS: trace of the error with markers=False (seaborn 0.13.2):

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev\pydevconsole.py", line 364, in runcode
    coro = func()
           ^^^^^^
  File "<input>", line 1, in <module>
  File "C:\...\venv\Lib\site-packages\seaborn\relational.py", line 636, in scatterplot
    p.plot(ax, kwargs)
  File "C:\...\venv\Lib\site-packages\seaborn\relational.py", line 425, in plot
    example_marker = self._style_map(example_level, "marker")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\venv\Lib\site-packages\seaborn\_base.py", line 85, in __call__
    return self._lookup_single(key, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\venv\Lib\site-packages\seaborn\_base.py", line 588, in _lookup_single
    value = self.lookup_table[key][attr]
            ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'marker'
@mwaskom
Copy link
Owner

mwaskom commented Mar 10, 2024

Hm this sounds like a regression, do you happen to know if it works on 0.11/0.12?

@jhncls
Copy link
Author

jhncls commented Mar 11, 2024

Testing with 0.13.2 / 0.13.0 / 0.12.2 / 0.12.0 / 0.11.2 / 0.11.0 all give the same error at the same line value = self.lookup_table[key][attr].

For a minimal test case: sns.scatterplot(data=[[7]], markers=False)

@mwaskom
Copy link
Owner

mwaskom commented Mar 11, 2024

Thanks for checking. Of note, lineplot handles this as expected

sns.lineplot(tips, markers=False, dashes=False)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants