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

clarify error message when using unsupported marginal plot type #4654

Open
wdecoster opened this issue Jul 5, 2024 · 0 comments
Open

clarify error message when using unsupported marginal plot type #4654

wdecoster opened this issue Jul 5, 2024 · 0 comments
Labels
documentation written for humans feature something new P3 not needed for current cycle

Comments

@wdecoster
Copy link

Hi,

The error below had me stumped for quite a while:

import plotly as px
px.scatter(x=[1,2,3], y=[2,3,4], marginal_x="density")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wdecoster/miniconda3/envs/data_analysis/lib/python3.12/site-packages/_plotly_utils/importers.py", line 39, in __getattr__
    raise AttributeError(
AttributeError: module 'plotly' has no attribute 'scatter'
>>> import plotly.express as px
^[[Apx.scatter(x=[1,2,3], y=[2,3,4], marginal_x="density")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wdecoster/miniconda3/envs/data_analysis/lib/python3.12/site-packages/plotly/express/_chart_types.py", line 66, in scatter
    return make_figure(args=locals(), constructor=go.Scatter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wdecoster/miniconda3/envs/data_analysis/lib/python3.12/site-packages/plotly/express/_core.py", line 2152, in make_figure
    trace = trace_spec.constructor(name=trace_name)
            ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'constructor'

It turns out that "density" is not a supported type for a marginal plot, and I should have used "violin" instead.
But could this error message perhaps be more explicit about what is going wrong?

Best,
Wouter

@gvwilson gvwilson self-assigned this Jul 12, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 not needed for current cycle label Aug 12, 2024
@gvwilson gvwilson changed the title Cryptic error message when using unsupported marginal plot type clarify error message when using unsupported marginal plot type Aug 13, 2024
@gvwilson gvwilson added feature something new documentation written for humans labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation written for humans feature something new P3 not needed for current cycle
Projects
None yet
Development

No branches or pull requests

2 participants