Skip to content

Commit e339a39

Browse files
committed
Python: add Group_Style and Group_Key_Labels to scatter plots
1 parent 7fbcbc0 commit e339a39

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

Utilities/Python/fdsplotlib.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,9 @@ def scatplot(saved_data, drange, **kwargs):
14701470
plot_type=Plot_Type,
14711471
x_min=Plot_Min, x_max=Plot_Max, y_min=Plot_Min, y_max=Plot_Max,
14721472
x_label=row["Ind_Title"],
1473-
y_label=row["Dep_Title"])
1473+
y_label=row["Dep_Title"],
1474+
legend_location='outside',
1475+
legend_expand=row["Paper_Width_Factor"])
14741476

14751477
fdsplotlib.plot_to_fig(x_data=[Plot_Min, Plot_Max], y_data=[Plot_Min, Plot_Max], line_style="k-", figure_handle=fig)
14761478
if Sigma_E > 0:
@@ -1480,8 +1482,42 @@ def scatplot(saved_data, drange, **kwargs):
14801482
fdsplotlib.plot_to_fig(x_data=[Plot_Min, Plot_Max], y_data=np.array([Plot_Min, Plot_Max]) * delta * (1 + 2 * Sigma_M), line_style="r--", figure_handle=fig)
14811483
fdsplotlib.plot_to_fig(x_data=[Plot_Min, Plot_Max], y_data=np.array([Plot_Min, Plot_Max]) * delta / (1 + 2 * Sigma_M), line_style="r--", figure_handle=fig)
14821484

1483-
# plot data last so it shows on top of stat lines
1484-
fdsplotlib.plot_to_fig(x_data=Measured_Values, y_data=Predicted_Values, marker_style="ko", figure_handle=fig)
1485+
# --- Plot each dataset with its own marker and color ---
1486+
seen_labels = set()
1487+
1488+
for idx in match_idx:
1489+
style = str(Save_Group_Style[idx]).strip() if Save_Group_Style[idx] else "ko"
1490+
fill = str(Save_Fill_Color[idx]).strip() if Save_Fill_Color[idx] else "none"
1491+
label = str(Save_Group_Key_Label[idx]).strip() if Save_Group_Key_Label[idx] else ""
1492+
1493+
# Flatten valid points for this dataset
1494+
mvals = np.array(Save_Measured_Metric[idx], dtype=float).flatten()
1495+
pvals = np.array(Save_Predicted_Metric[idx], dtype=float).flatten()
1496+
1497+
mask = (
1498+
(mvals >= Plot_Min) & (mvals <= Plot_Max) &
1499+
(pvals >= Plot_Min) & (pvals <= Plot_Max) &
1500+
(mvals > 0) & (pvals > 0)
1501+
)
1502+
mvals = mvals[mask]
1503+
pvals = pvals[mask]
1504+
1505+
if len(mvals) == 0:
1506+
continue
1507+
1508+
# Only assign a legend label once per experiment
1509+
data_label = label if label and label not in seen_labels else None
1510+
if label:
1511+
seen_labels.add(label)
1512+
1513+
fdsplotlib.plot_to_fig(
1514+
x_data=mvals,
1515+
y_data=pvals,
1516+
marker_style=style,
1517+
marker_facecolor=fill,
1518+
figure_handle=fig,
1519+
data_label=data_label,
1520+
)
14851521

14861522
pdf_path = os.path.join(Manuals_Dir, Plot_Filename + ".pdf")
14871523
os.makedirs(os.path.dirname(pdf_path), exist_ok=True)

0 commit comments

Comments
 (0)