in src/text_clustering.py [0:0]
def _show_plotly(self, df):
fig = px.scatter(
df,
x="X",
y="Y",
color="labels",
hover_data={"content_display": True, "X": False, "Y": False},
width=1600,
height=800,
color_continuous_scale="HSV",
)
fig.update_traces(hovertemplate="%{customdata[0]}<extra></extra>")
fig.update_traces(
marker=dict(size=1, opacity=0.8), # color="white"
selector=dict(mode="markers"),
)
fig.update_layout(
template="plotly_dark",
)
# show cluster summaries
for label in self.cluster_summaries.keys():
if label == -1:
continue
summary = self.cluster_summaries[label]
position = self.cluster_centers[label]
fig.add_annotation(
x=position[0],
y=position[1],
text=summary,
showarrow=False,
yshift=0,
)
fig.show()