# grab the lcd and pld values from both
lcd_mgr = np.array([d[0] if d is not None else None for d in iza_pore_dias])
lcd_zeo = iza_df['lcd'].values
pld_mgr = np.array([d[1] if d is not None else None for d in iza_pore_dias])
pld_zeo = iza_df['pld'].values
# Create subplots
fig = make_subplots(rows=1, cols=2, subplot_titles=("(a) LCD", "(b) PLD"),
horizontal_spacing=0.1)
# LCD subplot
fig.add_trace(
go.Scatter(
x=lcd_mgr,
y=lcd_zeo,
mode='markers',
marker=dict(size=10, line=dict(color='black', width=1)),
name='LCD Data'
),
row=1, col=1
)
fig.add_trace(
go.Scatter(
x=[0, max(lcd_zeo)+3],
y=[0, max(lcd_zeo)+3],
mode='lines',
line=dict(color='black', width=1, dash='dash'),
name='LCD Parity Line'
),
row=1, col=1
)
# PLD subplot
fig.add_trace(
go.Scatter(
x=pld_mgr, # Assuming you have pld_mgr data
y=pld_zeo, # Assuming you have pld_zeo data
mode='markers',
marker=dict(size=10, line=dict(color='black', width=1)),
name='PLD Data'
),
row=1, col=2
)
fig.add_trace(
go.Scatter(
x=[0, max(pld_zeo)+3],
y=[0, max(pld_zeo)+3],
mode='lines',
line=dict(color='black', width=1, dash='dash'),
name='PLD Parity Line'
),
row=1, col=2
)
# Update layout for both subplots
fig.update_layout(
template='simple_white',
showlegend=False,
font=dict(family='Arial'),
width=1200,
height=600,
autosize=False,
)
# Update x and y axes for both subplots
for i in [1, 2]:
fig.update_xaxes(
title=dict(text='MOFography (\u212b)', font=dict(size=14)),
tickfont=dict(size=12),
mirror=True,
showgrid=False,
range=[0, max(lcd_zeo if i == 1 else pld_zeo) + 3],
row=1, col=i
)
fig.update_yaxes(
title=dict(text='Zeo++ (\u212b)', font=dict(size=14)),
tickfont=dict(size=12),
mirror=True,
showgrid=False,
range=[0, max(lcd_zeo if i == 1 else pld_zeo) + 3],
row=1, col=i
)
# Function to remove NaN entries from both arrays
def remove_nan_pairs(arr1, arr2):
arr1 = np.array(arr1, dtype=float)
arr2 = np.array(arr2, dtype=float)
mask = ~np.isnan(arr1) & ~np.isnan(arr2)
return arr1[mask], arr2[mask]
# Remove NaN entries and compute R² and MAE for LCD
lcd_zeo_clean, lcd_mgr_clean = remove_nan_pairs(lcd_zeo, lcd_mgr)
lcd_r2 = r2_score(lcd_zeo_clean, lcd_mgr_clean)
lcd_mae = mean_absolute_error(lcd_zeo_clean, lcd_mgr_clean)
# Remove NaN entries and compute R² and MAE for PLD
pld_zeo_clean, pld_mgr_clean = remove_nan_pairs(pld_zeo, pld_mgr)
pld_r2 = r2_score(pld_zeo_clean, pld_mgr_clean)
pld_mae = mean_absolute_error(pld_zeo_clean, pld_mgr_clean)
# Add annotations for LCD
fig.add_annotation(
text=f"R²: {lcd_r2:.2f}<br>MAE: {lcd_mae:.2f} Å",
xref="x1", yref="y1",
x=0.05 * max(lcd_zeo), y=0.95 * max(lcd_zeo),
showarrow=False,
font=dict(size=14),
bgcolor="white",
opacity=0.8,
row=1, col=1
)
# Add annotations for PLD
fig.add_annotation(
text=f"R²: {pld_r2:.2f}<br>MAE: {pld_mae:.2f} Å",
xref="x2", yref="y2",
x=0.05 * max(pld_zeo), y=0.95 * max(pld_zeo),
showarrow=False,
font=dict(size=14),
bgcolor="white",
opacity=0.8,
row=1, col=2
)
fig.show()