Label plot axes.

master
junos 2023-05-17 16:32:27 +02:00
parent 0409c9e982
commit 2c5a0b4157
1 changed files with 21 additions and 11 deletions

View File

@ -74,15 +74,16 @@ df_esm_PANAS_summary_participant = (
.reset_index(col_level=1) .reset_index(col_level=1)
) )
df_esm_PANAS_summary_participant[ df_esm_PANAS_summary_participant[
"PANAS_subscale" "PANAS subscale"
] = df_esm_PANAS_daily_means.questionnaire_id.astype("category").cat.rename_categories( ] = df_esm_PANAS_daily_means.questionnaire_id.astype("category").cat.rename_categories(
{8.0: "PA", 9.0: "NA"} {8.0: "positive affect", 9.0: "negative affect"}
) )
# %% # %%
fig1 = sns.displot( fig1 = sns.displot(
data=df_esm_PANAS_summary_participant, x="mean", hue="PANAS_subscale", binwidth=0.2 data=df_esm_PANAS_summary_participant, x="mean", hue="PANAS subscale", binwidth=0.2
) )
fig1.set_axis_labels(x_var="participant mean", y_var="frequency")
if save_figs: if save_figs:
fig1.figure.savefig("PANAS_mean_participant.pdf", dpi=300) fig1.figure.savefig("PANAS_mean_participant.pdf", dpi=300)
@ -90,14 +91,15 @@ if save_figs:
sns.displot( sns.displot(
data=df_esm_PANAS_summary_participant, data=df_esm_PANAS_summary_participant,
x="median", x="median",
hue="PANAS_subscale", hue="PANAS subscale",
binwidth=0.2, binwidth=0.2,
) )
# %% # %%
fig2 = sns.displot( fig2 = sns.displot(
data=df_esm_PANAS_summary_participant, x="std", hue="PANAS_subscale", binwidth=0.05 data=df_esm_PANAS_summary_participant, x="std", hue="PANAS subscale", binwidth=0.05
) )
fig2.set_axis_labels(x_var="participant standard deviation", y_var="frequency")
if save_figs: if save_figs:
fig2.figure.savefig("PANAS_std_participant.pdf", dpi=300) fig2.figure.savefig("PANAS_std_participant.pdf", dpi=300)
@ -148,6 +150,9 @@ df_esm_SAM_event_summary_participant = (
# %% # %%
fig6 = sns.displot(data=df_esm_SAM_event_summary_participant, x="mean", binwidth=0.1) fig6 = sns.displot(data=df_esm_SAM_event_summary_participant, x="mean", binwidth=0.1)
fig6.set_axis_labels(
x_var="participant proportion of stressful events", y_var="frequency"
)
if save_figs: if save_figs:
fig6.figure.savefig("SAM_events_mean_participant.pdf", dpi=300) fig6.figure.savefig("SAM_events_mean_participant.pdf", dpi=300)
@ -194,7 +199,7 @@ df_esm_SAM_threat_challenge_summary_participant = df_esm_SAM_summary_participant
| (df_esm_SAM_summary_participant["questionnaire_id"] == 89) | (df_esm_SAM_summary_participant["questionnaire_id"] == 89)
] ]
df_esm_SAM_threat_challenge_summary_participant[ df_esm_SAM_threat_challenge_summary_participant[
"event_subscale" "event subscale"
] = df_esm_SAM_threat_challenge_summary_participant.questionnaire_id.astype( ] = df_esm_SAM_threat_challenge_summary_participant.questionnaire_id.astype(
"category" "category"
).cat.rename_categories( ).cat.rename_categories(
@ -205,7 +210,7 @@ df_esm_SAM_threat_challenge_summary_participant[
sns.displot( sns.displot(
data=df_esm_SAM_threat_challenge_summary_participant, data=df_esm_SAM_threat_challenge_summary_participant,
x="mean", x="mean",
hue="event_subscale", hue="event subscale",
binwidth=0.2, binwidth=0.2,
) )
@ -213,9 +218,10 @@ sns.displot(
fig3 = sns.displot( fig3 = sns.displot(
data=df_esm_SAM_threat_challenge_summary_participant, data=df_esm_SAM_threat_challenge_summary_participant,
x="std", x="std",
hue="event_subscale", hue="event subscale",
binwidth=0.1, binwidth=0.1,
) )
fig3.set_axis_labels(x_var="participant standard deviation", y_var="frequency")
if save_figs: if save_figs:
fig3.figure.savefig("SAM_std_participant.pdf", dpi=300) fig3.figure.savefig("SAM_std_participant.pdf", dpi=300)
@ -263,7 +269,7 @@ df_esm_JCQ_summary_participant = (
.reset_index(col_level=1) .reset_index(col_level=1)
) )
df_esm_JCQ_summary_participant[ df_esm_JCQ_summary_participant[
"JCQ_subscale" "JCQ subscale"
] = df_esm_JCQ_summary_participant.questionnaire_id.astype( ] = df_esm_JCQ_summary_participant.questionnaire_id.astype(
"category" "category"
).cat.rename_categories( ).cat.rename_categories(
@ -274,9 +280,10 @@ df_esm_JCQ_summary_participant[
fig4 = sns.displot( fig4 = sns.displot(
data=df_esm_JCQ_summary_participant, data=df_esm_JCQ_summary_participant,
x="mean", x="mean",
hue="JCQ_subscale", hue="JCQ subscale",
binwidth=0.1, binwidth=0.1,
) )
fig4.set_axis_labels(x_var="participant mean", y_var="frequency")
if save_figs: if save_figs:
fig4.figure.savefig("JCQ_mean_participant.pdf", dpi=300) fig4.figure.savefig("JCQ_mean_participant.pdf", dpi=300)
@ -284,8 +291,11 @@ if save_figs:
fig5 = sns.displot( fig5 = sns.displot(
data=df_esm_JCQ_summary_participant, data=df_esm_JCQ_summary_participant,
x="std", x="std",
hue="JCQ_subscale", hue="JCQ subscale",
binwidth=0.05, binwidth=0.05,
) )
fig6.set_axis_labels(x_var="participant standard deviation", y_var="frequency")
if save_figs: if save_figs:
fig5.figure.savefig("JCQ_std_participant.pdf", dpi=300) fig5.figure.savefig("JCQ_std_participant.pdf", dpi=300)
# %%