Spaces:
Sleeping
Sleeping
Commit
·
b94baa7
1
Parent(s):
2f05ff8
Fix Images Not Rendered when Hovering over Plot 2
Browse files
app.py
CHANGED
@@ -862,9 +862,10 @@ def run_model(model_name):
|
|
862 |
title="PCA - Todos los subconjuntos proyectados",
|
863 |
plot_width=600,
|
864 |
plot_height=600,
|
865 |
-
tools="pan,wheel_zoom,reset,save
|
866 |
active_scroll="wheel_zoom",
|
867 |
-
background_fill_color="white"
|
|
|
868 |
)
|
869 |
# Solo grid horizontal
|
870 |
fig_all.xgrid.grid_line_color = None
|
@@ -876,7 +877,8 @@ def run_model(model_name):
|
|
876 |
source = ColumnDataSource(data={
|
877 |
'x': subset['x'],
|
878 |
'y': subset['y'],
|
879 |
-
'label': subset['label']
|
|
|
880 |
})
|
881 |
# Usamos 'circle' para las reales
|
882 |
fig_all.circle('x', 'y', size=10,
|
@@ -902,7 +904,8 @@ def run_model(model_name):
|
|
902 |
source = ColumnDataSource(data={
|
903 |
'x': subset['x'],
|
904 |
'y': subset['y'],
|
905 |
-
'label': subset['label']
|
|
|
906 |
})
|
907 |
# Usamos 'triangle' para pretrained (por ejemplo)
|
908 |
fig_all.triangle('x', 'y', size=10,
|
@@ -918,15 +921,27 @@ def run_model(model_name):
|
|
918 |
radius = distances.max()
|
919 |
|
920 |
# Dibujar el centroide y la circunferencia en el plot
|
921 |
-
fig_all.circle(
|
922 |
-
|
923 |
-
|
924 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
925 |
|
926 |
fig_all.xaxis.axis_label = "PC1"
|
927 |
fig_all.yaxis.axis_label = "PC2"
|
928 |
hover_all = fig_all.select_one(HoverTool)
|
929 |
-
hover_all.
|
|
|
|
|
930 |
|
931 |
# Agregar checkbox para mostrar u ocultar la leyenda, igual que en el primer PCA
|
932 |
show_legend_second = st.checkbox("Show Legend", value=False, key=f"legend_second_{model_name}")
|
|
|
862 |
title="PCA - Todos los subconjuntos proyectados",
|
863 |
plot_width=600,
|
864 |
plot_height=600,
|
865 |
+
tools="pan,wheel_zoom,reset,save",
|
866 |
active_scroll="wheel_zoom",
|
867 |
+
background_fill_color="white",
|
868 |
+
tooltips=TOOLTIPS
|
869 |
)
|
870 |
# Solo grid horizontal
|
871 |
fig_all.xgrid.grid_line_color = None
|
|
|
877 |
source = ColumnDataSource(data={
|
878 |
'x': subset['x'],
|
879 |
'y': subset['y'],
|
880 |
+
'label': subset['label'],
|
881 |
+
'img': subset['img']
|
882 |
})
|
883 |
# Usamos 'circle' para las reales
|
884 |
fig_all.circle('x', 'y', size=10,
|
|
|
904 |
source = ColumnDataSource(data={
|
905 |
'x': subset['x'],
|
906 |
'y': subset['y'],
|
907 |
+
'label': subset['label'],
|
908 |
+
'img': subset['img']
|
909 |
})
|
910 |
# Usamos 'triangle' para pretrained (por ejemplo)
|
911 |
fig_all.triangle('x', 'y', size=10,
|
|
|
921 |
radius = distances.max()
|
922 |
|
923 |
# Dibujar el centroide y la circunferencia en el plot
|
924 |
+
centroid_glyph = fig_all.circle(
|
925 |
+
x=center_x, y=center_y, size=15,
|
926 |
+
fill_color="white", line_color="black",
|
927 |
+
legend_label="Centroide",
|
928 |
+
name="centroid" # Asigna un nombre único
|
929 |
+
)
|
930 |
+
|
931 |
+
circumference_glyph = fig_all.circle(
|
932 |
+
x=center_x, y=center_y, radius=radius,
|
933 |
+
fill_color=None, line_color="black",
|
934 |
+
line_dash="dashed",
|
935 |
+
legend_label="Circunferencia",
|
936 |
+
name="circumference" # Asigna un nombre único
|
937 |
+
)
|
938 |
|
939 |
fig_all.xaxis.axis_label = "PC1"
|
940 |
fig_all.yaxis.axis_label = "PC2"
|
941 |
hover_all = fig_all.select_one(HoverTool)
|
942 |
+
hover_all.renderers = [r for r in fig_all.renderers if r.name not in ["centroid", "circumference"]]
|
943 |
+
|
944 |
+
# hover_all.tooltips = [("Label", "@label"), ("PC1", "@x"), ("PC2", "@y")]
|
945 |
|
946 |
# Agregar checkbox para mostrar u ocultar la leyenda, igual que en el primer PCA
|
947 |
show_legend_second = st.checkbox("Show Legend", value=False, key=f"legend_second_{model_name}")
|