Skip to content

Unrenderable violin plot #5261

Open
Open
@slambert-git

Description

@slambert-git

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2considered for next cyclebugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions