forked from gabrielchua/RAGxplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplots.py
40 lines (36 loc) · 1.18 KB
/
plots.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import streamlit as st
import plotly.graph_objs as go
from constants import VISUALISATION_SETTINGS
def plot_embeddings(df):
# Create a figure
fig = go.Figure()
for category in df['category'].unique():
category_df = df[df['category'] == category]
settings = VISUALISATION_SETTINGS.get(category, {'color': 'grey', 'opacity': 1, 'symbol': 'circle', 'size': 10})
fig.add_trace(go.Scatter(
x=category_df['x'],
y=category_df['y'],
mode='markers',
name=category,
marker=dict(
color=settings['color'],
opacity=settings['opacity'],
symbol=settings['symbol'],
size=settings['size'],
line_width=0
),
hoverinfo='text',
text=category_df['document_cleaned']
))
# Set the layout, including moving the legend to the top
fig.update_layout(
height=500,
legend=dict(
y=100,
x=0.5,
xanchor='center',
yanchor='top',
orientation='h'
)
)
return st.plotly_chart(fig, use_container_width=True)