Unrenderable violin plot

Open
#5,261 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
pandas, plotly, python

Research direction

Start by running the provided Python script with the attached df_melted.csv under Python 3.13.5, then inspect test_plot.html and reproduce the notebook crash. Trace the violin plot rendering path for this input; done means the generated HTML renders and the same figure no longer crashes notebooks.

Written by the indexing model from the issue text.

Description

bug P2

I have some example input here and a script for creating a violin plot. The plot writes without error but appears unrenderable, it never displays and will e.g., cause notebooks to crash.

Python 3.13.5
plotly 6.0.1
pandas 2.2.3
import pandas as pd
import plotly.express as px
from plotly.graph_objects import Figure


def create_plot(df: pd.DataFrame) -> Figure:
    fig = px.violin(
        df,
        color='sample',
        color_discrete_sequence=px.colors.qualitative.Safe,
        y='value',
        x='sample',
        points=False,
        box=True,
        facet_col='metric',
        facet_col_wrap=1,
    )
    fig.update_yaxes(matches=None)
    fig.update_xaxes(matches=None)
    fig.update_layout(height=400 * len(df['metric'].unique()))
    return fig


if __name__ == '__main__':
    file = 'df_melted.csv'
    df = pd.read_csv(file)
    fig = create_plot(df)
    fig.write_html('test_plot.html')

Example input file is attached. The input is admittedly unusual for a violin plot (essentially all 0s or all 1s).

Thanks in advance!

df_melted.csv

Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
13h 41m
Merged PRs (30d)
21

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plotly/plotly.py

All issues in plotly/plotly.py

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.