Py.Cafe

iisakkirotko/

solara-issue-66

Analyzing Conversation Intents with Plotly and Solara

DocsPricing
  • app.py
  • conv_intent.csv
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pandas as pd
import solara as sl
import plotly.express as px

@sl.component
def Page():
    df = pd.read_csv("conv_intent.csv")
    df["text_length"] = df.text.str.len()
    df["id"] = list(range(len(df)))
    df["hovertext"] = df.text.str.wrap(30).str.replace("\n", "<br>")
    fig = px.scatter(
        df,
        x="x",
        y="y",
        custom_data=[df["id"]],
        hover_data=["hovertext"],
    )
    fig.update_layout(showlegend=False)
    fig.update_xaxes(visible=False)
    fig.update_yaxes(visible=False)
    fig.update_traces(marker_size=2)
    
    sl.FigurePlotly(fig)
    
Page()
requirements.txt
1
2
3
solara
pandas
plotly