<jupyter_start><jupyter_text><jupyter_code>df_i = df_features_targets[[
    ("targets", "g_o", "", ),
    ("targets", "g_oh", "", ),
    ("targets", "g_o_m_oh", "", ),

    # ("features", "o", "effective_ox_state", ),
    # ("features", "oh", "effective_ox_state", ),

    ("features", "effective_ox_state", "", ),

    ]]
# target = "g_oh"
target = "g_o"

feature_ads = "oh"<jupyter_output><empty_output><jupyter_text>Figuring out the mean DG_O at every eff. ox. state<jupyter_code># eff_ox_vals = df_i[("features", "o", "effective_ox_state")].unique()

# eff_ox_vals = df_i[("features", feature_ads, "effective_ox_state")].unique()
eff_ox_vals = df_i[("features", "effective_ox_state", "", )].unique()

eff_ox_vals = eff_ox_vals.tolist()
eff_ox_vals = list(np.sort(eff_ox_vals)[:-1])

eff_ox_vals_uniq = list(np.unique(
    [np.round(i, 10) for i in eff_ox_vals]
    ))


data_dict_list = []
for eff_ox_i in eff_ox_vals_uniq:

    # col_ind = ("features", feature_ads, "effective_ox_state")
    col_ind = ("features", "effective_ox_state", "", )

    df_tmp_0 = df_i[
        (df_i[col_ind] < eff_ox_i + 0.001) & \
        (df_i[col_ind] > eff_ox_i - 0.001)
        ]

    ave_ads_e_i = df_tmp_0[("targets", target, "")].mean()

    # #####################################################
    data_dict_i = dict()
    # #####################################################
    data_dict_i["eff_ox"] = eff_ox_i
    data_dict_i["ads_e_ave"] = ave_ads_e_i
    # #####################################################
    data_dict_list.append(data_dict_i)
    # #####################################################

df_eff_ox_ave = pd.DataFrame(data_dict_list)<jupyter_output><empty_output><jupyter_text>Drop some indiv. rows<jupyter_code>rows_to_drop = [
    # ("sherlock", "vipikema_98", 53.0, ),
    ("slac", "dabipilo_28", 59.0, ),
    ("sherlock", "vipikema_98", 47.0, ),
    ]

if False:
    df_i = df_i.drop(index=rows_to_drop)
# df_i[df_i[("features", "oh", "effective_ox_state", )] == 6.0]

# df_i[df_i[("features", "oh", "effective_ox_state", )] == 6.000000000000001]

# df_i[("features", "oh", "effective_ox_state", )].tolist()
df_j = df_i[[
    ("targets", target, ""),
    # ("features", feature_ads, "effective_ox_state"),
    ("features", "effective_ox_state", "", ),
    ]]

df_j = df_j.dropna()
trace_mean = go.Scatter(
    x=df_eff_ox_ave["eff_ox"],
    y=df_eff_ox_ave["ads_e_ave"],
    mode="markers+lines",
    marker=go.scatter.Marker(
        size=8,
        ),
    line=go.scatter.Line(
        color="black",
        width=2,
        ),
    )
scatter_shared_props_cpy = copy.deepcopy(scatter_shared_props)

tmp = scatter_shared_props_cpy.update(dict(marker=dict(size=8, )))
layout_cpy = copy.deepcopy(layout_shared)

if target == "g_oh":
    y_axis_title = "ΔG<sub>OH</sub> (eV)"
elif target == "g_o":
    y_axis_title = "ΔG<sub>O</sub> (eV)"

# layout_shared
layout_mine = go.Layout(
    # width=20 * 37.795275591,
    # height=20 / 1.61803398875 * 37.795275591,

    # width=14 * 37.795275591,
    # height=14 / 1.61803398875 * 37.795275591,

    # width=14 * 37.795275591,
    # height=14 / 1.61803398875 * 37.795275591,

    width=12 * 37.795275591,
    height=12 / 1.61803398875 * 37.795275591,

    margin=go.layout.Margin(
        b=10, l=10,
        r=10, t=10,
        ),

    showlegend=False,

    xaxis=go.layout.XAxis(
        tickfont=go.layout.xaxis.Tickfont(
            size=font_tick_labels_size__pub,
            ),

        title=dict(
            text="Ir Effective Oxidation State",
            font=dict(
                size=font_axis_title_size__pub,
                ),
            )
        ),
    yaxis=go.layout.YAxis(
        tickfont=go.layout.yaxis.Tickfont(
            size=font_tick_labels_size__pub,
            ),

        title=dict(
            # text="ΔG<sub>OH</sub> (eV)",
            text=y_axis_title,
            font=dict(
                size=font_axis_title_size__pub,
                ),
            )
        ),
    )
tmp = layout_cpy.update(layout_mine)







ab2_indices = df_features_targets[
    df_features_targets[("data", "stoich", "", )] == "AB2"].index.tolist()
ab3_indices = df_features_targets[
    df_features_targets[("data", "stoich", "", )] == "AB3"].index.tolist()

df_j_ab3 = df_j.loc[
    df_j.index.intersection(ab3_indices)
    ]

df_j_ab2 = df_j.loc[
    df_j.index.intersection(ab2_indices)
    ]





# x_array = df_j_ab2[('features', feature_ads, 'effective_ox_state')]
x_array = df_j_ab2[('features', 'effective_ox_state', "", )]
y_array = df_j_ab2[('targets', target, '')]

trace_ab2 = go.Scatter(
    x=x_array,
    y=y_array,
    mode="markers",
    marker_color=stoich_color_dict["AB2"],
    )
trace_ab2.update(
    scatter_shared_props_cpy,
    )

# x_array = df_j_ab3[('features', feature_ads, 'effective_ox_state')]
x_array = df_j_ab3[('features', 'effective_ox_state', "", )]
y_array = df_j_ab3[('targets', target, '')]

trace_ab3 = go.Scatter(
    x=x_array,
    y=y_array,
    mode="markers",
    marker_color=stoich_color_dict["AB3"],
    )
trace_ab3.update(
    scatter_shared_props_cpy,
    )




data = [trace_mean, trace_ab2, trace_ab3, ]

fig = go.Figure(data=data, layout=layout_cpy)
fig.show()
df_j_ab3

# df_j_ab2
# assert False
from plotting.my_plotly import my_plotly_plot

my_plotly_plot(
    figure=fig,
    plot_name="G_O__vs__eff_ox",
    write_html=True,
    write_pdf=True,
    try_orca_write=True,
    )<jupyter_output><empty_output><jupyter_text>Creating box plots for Eff ox state<jupyter_code># import plotly.express as px
# df = px.data.tips()
# fig = px.box(df, x="time", y="total_bill")
# fig.show()
# # df_j_ab3[("features", "oh", "effective_ox_state", )] = np.round(
# df_j_ab3[("features", "effective_ox_state", "", )] = np.round(
#     # df_j_ab3[("features", "oh", "effective_ox_state", )],
#     df_j_ab3[("features", "effective_ox_state", "", )],
#     5,
#     )


# # df_j_ab2[("features", "oh", "effective_ox_state", )] = np.round(
# df_j_ab2[("features", "effective_ox_state", "", )] = np.round(
#     # df_j_ab2[("features", "oh", "effective_ox_state", )],
#     df_j_ab2[("features", "effective_ox_state", "", )],
#     5,
#     )
# df_j_ab3.columns.tolist()

# ('targets', 'g_o', '')
# ('features', 'oh', 'effective_ox_state')
new_cols = []
for col_i in df_j_ab2.columns:
    if col_i[0] == "targets":
        new_col_i = "target"
        new_cols.append(new_col_i)
    elif col_i[0] == "features":
        new_col_i = "eff_ox"
        new_cols.append(new_col_i)
    else:
        new_cols.append("TEMP")

# new_cols

df_j_ab2.columns = new_cols

# df_j_ab3
df_j_ab3
new_cols = []
for col_i in df_j_ab3.columns:
    if col_i[0] == "targets":
        new_col_i = "target"
        new_cols.append(new_col_i)
    elif col_i[0] == "features":
        new_col_i = "eff_ox"
        new_cols.append(new_col_i)
    else:
        new_cols.append("TEMP")

# new_cols

df_j_ab3.columns = new_cols

df_j_ab3
df_j_2 = pd.concat([
    df_j_ab2,
    df_j_ab3,
    ],
    axis=0)

df_j_2
import plotly.express as px

# df = px.data.tips()
# df = df_j_ab3
df = df_j_2

fig = px.box(df, x="eff_ox", y="target")
fig.show()
# fig.layout
# df
layout_cpy = copy.deepcopy(layout_shared)

if target == "g_oh":
    y_axis_title = "ΔG<sub>OH</sub> (eV)"
elif target == "g_o":
    y_axis_title = "ΔG<sub>O</sub> (eV)"

# layout_shared
layout_mine = go.Layout(
    # width=20 * 37.795275591,
    # height=20 / 1.61803398875 * 37.795275591,

    # width=14 * 37.795275591,
    # height=14 / 1.61803398875 * 37.795275591,

    # width=14 * 37.795275591,
    # height=14 / 1.61803398875 * 37.795275591,

    width=12 * 37.795275591,
    height=12 / 1.61803398875 * 37.795275591,

    margin=go.layout.Margin(
        b=10, l=10,
        r=10, t=10,
        ),

    showlegend=False,

    xaxis=go.layout.XAxis(
        tickfont=go.layout.xaxis.Tickfont(
            size=font_tick_labels_size__pub,
            ),

        title=dict(
            text="Ir Effective Oxidation State",
            font=dict(
                size=font_axis_title_size__pub,
                ),
            )
        ),
    yaxis=go.layout.YAxis(
        tickfont=go.layout.yaxis.Tickfont(
            size=font_tick_labels_size__pub,
            ),

        title=dict(
            # text="ΔG<sub>OH</sub> (eV)",
            text=y_axis_title,
            font=dict(
                size=font_axis_title_size__pub,
                ),
            )
        ),
    )
tmp = layout_cpy.update(layout_mine)

fig.update_layout(dict1=layout_cpy)
from plotting.my_plotly import my_plotly_plot

my_plotly_plot(
    figure=fig,
    save_dir=None,
    place_in_out_plot=True,
    plot_name="box_plot_G_O_eff_ox",
    write_html=True,
    write_png=False,
    png_scale=6.0,
    write_pdf=False,
    write_svg=False,
    try_orca_write=True,
    verbose=False,
    )
# df_eff_ox_ave<jupyter_output><empty_output><jupyter_text><jupyter_code># layout_cpy
# eff_ox_vals
# np.sort(df_j[("features", "oh", "effective_ox_state", )].tolist()).tolist()
# import chart_studio.plotly as py
# import plotly.graph_objs as go

# import os

# x_array = [0, 1, 2, 3]
# y_array = [0, 1, 2, 3]


# trace = go.Scatter(
#     x=x_array,
#     y=y_array,
#     mode="markers",
#     opacity=0.8,
#     marker=dict(

#         symbol="circle",
#         color='LightSkyBlue',

#         opacity=0.8,

#         # color=z,
#         colorscale='Viridis',
#         colorbar=dict(thickness=20),

#         size=20,
#         line=dict(
#             color='MediumPurple',
#             width=2
#             )
#         ),

#     line=dict(
#         color="firebrick",
#         width=2,
#         dash="dot",
#         ),

#     error_y={
#         "type": 'data',
#         "array": [0.4, 0.9, 0.3, 1.1],
#         "visible": True,
#         },

#     )

# data = [trace]

# fig = go.Figure(data=data)
# fig.show()

# go.scatter.Marker?
# go.Scatter?
# go.scatter.Line?
# tmp
# font_axis_title_size__pub, font_tick_labels_size__pub
# layout.XAxis({
#     'linecolor': 'black',
#     'mirror': True,
#     'showgrid': False,
#     'showline': True,
#     'tickcolor': 'black',
#     'tickfont': {'family': 'Arial', 'size': 20.0},
#     'ticks': 'outside',
#     'title': {'font': {'color': 'black', 'family': 'Arial', 'size': 24.0}, 'text': 'Ir Effective Oxidation State'}
# })
# font_tick_labels_size__pub
# fig.layout.xaxis.tickfont

# layout.xaxis.Tickfont({
#     'family': 'Arial', 'size': 20.0
# })
# fig.layout.xaxis.tickfont

# layout.xaxis.Tickfont({
#     'family': 'Arial', 'size': 20.0
# })<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18244454931571497, 'fraction_numerical': 0.04369985842378481, 'mean_word_length': 3.0365714285714285, 'pattern_counts': {'":': 11, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '653238', 'license': 'MIT', 'n_tokens_mistral': 4534, 'n_tokens_neox': 4213, 'n_words': 594, 'path': 'workflow/oer_vs_features/misc_oer_vs_feat_plots.ipynb', 'repo_name': 'raulf2012/PROJ_IrOx_OER', 'size': '10595'}