Sunburst chart not generating

29 Views Asked by At

I'm attempting to create a Sunburst chart using Plotly in Python, but for some reason, the plot is not generating. Below is the code I'm using:

import plotly.graph_objects as go

# Define the data
data = {
    'Length Scales': {
        'BRINKMAN SCREENING DISTANCE': '10**-12 — 10**-3 m',
        'PORE SIZE (OR PARTICLE SIZE)': '10**-10 — 10**-2 m',
        'REPRESENTATIVE ELEMENTARY VOLUME': '10**-8 — 1 m',
        'LINEAR DIMENSION OF SYSTEM': '10**-6 — 10**2',
    },
    'Time Scales': {
        'K1/2 << d': {
            'd': '10**-15 — 10 s',
            'l': '1**-11 — 10**5 s',
            'L': '10**-7 — 10**7 s',
        },
        'K1/2 < d < l': {
            'd': '10**-15 — 10 s',
            'l': '10**-11 — 10**5 s',
            'L': '10**-7 — 10**7 s',
        },
        'K1/2 >> l': {
            'd': '0 — 10**3 s',
            'l': '10**-15 — 10 s',
            'L': '10**-11 — 10**5 s',
        }
    },
    'Temperature Scales': {
        'ΔTK1/2 = 0': {
            'ΔTK1/2 < ΔTd': '0 — 10**-3 °C',
            'ΔTd < ΔTl < ΔTL': '0.1 — 10 °C',
            'ΔTL': '1 — 10**3 °C',
        },
        '0': {
            '0 — 10**-3 °C': None,
            '0.1 — 10 °C': None,
            '1 — 10**3 °C': None,
        }
    }
}

# Function to convert data into sunburst format
def create_sunburst_data(data, parent=''):
    sunburst_data = []
    for key, value in data.items():
        if isinstance(value, dict):
            sunburst_data.append(dict(
                name=key,
                children=create_sunburst_data(value, parent=key)
            ))
        else:
            sunburst_data.append(dict(
                name=key,
                value=value,
                parent=parent,
            ))
    return sunburst_data

# Create sunburst chart
fig = go.Figure(go.Sunburst(
    ids=[*data],
    labels=[*data],
    parents=[''] * len(data),
    values=[None] * len(data),
))

fig.update_layout(
    title_text="Sunburst Chart for Length, Time, and Temperature Scales",
    # Other layout customizations
)

fig.show()

The code runs without any errors, but the plot is not displayed. I've checked for potential issues with the Plotly installation, data formatting, and layout customization, but I haven't been able to identify the problem. Could someone please help me understand why the plot is not generating and how I can fix it?

Scales Table

0

There are 0 best solutions below