Skip to content

Commit

Permalink
Merge pull request #771 from haddocking/correct_crossbars
Browse files Browse the repository at this point in the history
corrected crossbar values
  • Loading branch information
mgiulini authored Jan 5, 2024
2 parents f3d89c6 + 29cc975 commit c7e6761
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/haddock/libs/libplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ def _build_hover_text(df):
else:
cl_name = f"Cluster {cl_rank[cl_id]}" # use rank
color_idx = (cl_rank[cl_id] - 1) % n_colors # color index
x_mean = np.mean(cl_df[x_ax])
y_mean = np.mean(cl_df[y_ax])

traces.append(
go.Scatter(
x=cl_df[x_ax],
Expand All @@ -399,20 +398,28 @@ def _build_hover_text(df):
)
)
clt_text = f"{cl_name}<br>"

# mean and std deviations for the top 4 members
x_mean = np.mean(cl_df[x_ax].iloc[:4])
y_mean = np.mean(cl_df[y_ax].iloc[:4])
x_std = np.std(cl_df[x_ax].iloc[:4])
y_std = np.std(cl_df[y_ax].iloc[:4])

if "score" not in [x_ax, y_ax]:
clt_text += f"Score: {np.mean(cl_df['score']):.3f}<br>"
clt_text += f"Score: {np.mean(cl_df['score'].iloc[:4]):.3f}<br>"
clt_text += f"{x_ax}: {x_mean:.3f}<br>{y_ax}: {y_mean:.3f}"

clt_text_list = [clt_text]
traces.append(
go.Scatter(
x=[x_mean],
y=[y_mean],
# error bars
error_x=dict(
type="data", array=[np.std(cl_df[x_ax])], visible=True
type="data", array=[x_std], visible=True
),
error_y=dict(
type="data", array=[np.std(cl_df[y_ax])], visible=True
type="data", array=[y_std], visible=True
),
# color and text
marker_color=colors[color_idx],
Expand Down

0 comments on commit c7e6761

Please sign in to comment.