Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

clarify error message when using unsupported marginal plot type #4654

Open
Labels
P3backlog documentationwritten for humans featuresomething new
@wdecoster

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlog documentationwritten for humans featuresomething new

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /