import plotly.express as px
import plotly.graph_objects as go
# 1. Plot F2 (Base Layer): Blue Squares
fig = px.scatter(F2, x='Dim 1', y='Dim 2', text=F2.index)
fig.update_traces(
textposition='top center', # Shifts text up
marker=dict(
color='blue',
symbol='diamond',
size=12 # Increases point size
)
)
# 2. Add G2 (Second Layer): Red Round (Circle)
trace_g2 = px.scatter(G2, x='Dim 1', y='Dim 2', text=G2.index)
trace_g2.update_traces(
textposition='top center', # Shifts text up
marker=dict(
color='red',
symbol='circle',
size=12 # Increases point size
)
)
fig.add_trace(trace_g2.data[0])
# 3. Add Lines: Gray and Dashed
fig.add_trace(go.Scatter(
x=[-0.4, 0.7], y=[0,0], mode='lines',
line=dict(color='gray', dash='dash', width=1)
))
fig.add_trace(go.Scatter(
x=[0,0], y=[min(G2['Dim 2'])*1.5, 0.15], mode='lines',
line=dict(color='gray', dash='dash', width=1)
))
fig.update_layout(width=600, height=250, showlegend=False)
fig.show()