I have a script that creates an interactive PCA plot with a widget so the PCA.
Meaning a script that I can change the x-axis and the y-axis with a dropdown menu.
The plot in the notebook looks like this:
However, if download as an HTML file using the File> Download as> html
The plot is not displayed. This is the script i used:
from ipywidgets import interact, interact_manual
@interact
def scatter_plot(x=list(components_df.select_dtypes('number').columns),
y=list(components_df.select_dtypes('number').columns)[1:]):
fig = px.scatter(components_df, x=x , y=y ,
color=dataTable_1['Class'], width=1000, height=700,
template='presentation',
labels=labels,
title="PCA Score Plot (PC{} vs. PC{})".format(1, 2) ,
# hover_name=df1.index,
hover_data=['idx', 'SampleID']
)
fig.show(config=config)
If I do not use the widget (remove the parts of the black arrows from the pic) I can create an interactive plot (with only the first two components of the PCA) the can be displayed in HTML file ( from the notebook)
A sample data:
d = {0: [1, 2, 3, 2, 1], 1: [1, 4, 5, 8, 11], 2: [2, 6, 2, 3, 2],3: [4, 2, 2, 6, 2], 4: [-1, 2, 23, -2, 2], 'idx': [1, 2,3,4,5],'SampleID': ['Area: 25', 'Area: 26','Area: 27','Area: 28','Area: 29']}
components_df= pd.DataFrame(data=d)
Kindly help and if any other information is needed please let me know Many thanks!
Already checked these links and others but could not find any answers