save figures to directory
This commit is contained in:
@@ -49,7 +49,7 @@ def _():
|
||||
def _(JPMCSurvey, QSF_FILE, RESULTS_FILE):
|
||||
survey = JPMCSurvey(RESULTS_FILE, QSF_FILE)
|
||||
data_all = survey.load_data()
|
||||
# data_all.collect()
|
||||
data_all.collect()
|
||||
return data_all, survey
|
||||
|
||||
|
||||
@@ -161,28 +161,27 @@ def _(mo):
|
||||
@app.cell
|
||||
def _(data, survey):
|
||||
char_rank = survey.get_character_ranking(data)[0].collect()
|
||||
|
||||
return (char_rank,)
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(char_rank, mo, plot_top3_ranking_distribution):
|
||||
def _(char_rank, mo, plot_top3_ranking_distribution, survey):
|
||||
mo.md(f"""
|
||||
### 1. Which character personality is ranked best?
|
||||
|
||||
|
||||
{mo.ui.plotly(plot_top3_ranking_distribution(char_rank, x_label='Character Personality', width=1000))}
|
||||
{mo.ui.plotly(plot_top3_ranking_distribution(char_rank, x_label='Character Personality', width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(char_rank, mo, plot_most_ranked_1):
|
||||
def _(char_rank, mo, plot_most_ranked_1, survey):
|
||||
mo.md(f"""
|
||||
### 2. Which character personality is ranked 1st the most?
|
||||
|
||||
|
||||
{mo.ui.plotly(plot_most_ranked_1(char_rank, title="Most Popular Character<br>(Number of Times Ranked 1st)", x_label='Character Personality', width=1000))}
|
||||
{mo.ui.plotly(plot_most_ranked_1(char_rank, title="Most Popular Character<br>(Number of Times Ranked 1st)", x_label='Character Personality', width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
@@ -193,6 +192,7 @@ def _(
|
||||
char_rank,
|
||||
mo,
|
||||
plot_weighted_ranking_score,
|
||||
survey,
|
||||
):
|
||||
char_rank_weighted = calculate_weighted_ranking_scores(char_rank)
|
||||
# plot_weighted_ranking_score(char_rank_weighted, x_label='Voice', width=1000)
|
||||
@@ -201,7 +201,7 @@ def _(
|
||||
### 3. Which character personality most popular based on weighted scores?
|
||||
|
||||
|
||||
{mo.ui.plotly(plot_weighted_ranking_score(char_rank_weighted, title="Most Popular Character - Weighted Popularity Score<br>(1st=3pts, 2nd=2pts, 3rd=1pt)", x_label='Voice', width=1000))}
|
||||
{mo.ui.plotly(plot_weighted_ranking_score(char_rank_weighted, title="Most Popular Character - Weighted Popularity Score<br>(1st=3pts, 2nd=2pts, 3rd=1pt)", x_label='Voice', width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
@@ -222,69 +222,66 @@ def _(data, survey):
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
def _(mo, plot_voice_selection_counts, v_18_8_3):
|
||||
def _(mo, plot_voice_selection_counts, survey, v_18_8_3):
|
||||
mo.md(f"""
|
||||
### Which 8 voices are chosen the most out of 18?
|
||||
|
||||
{mo.ui.plotly(plot_voice_selection_counts(v_18_8_3, height=500, width=1000))}
|
||||
{mo.ui.plotly(plot_voice_selection_counts(v_18_8_3, height=500, width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
def _(mo, plot_top3_selection_counts, v_18_8_3):
|
||||
def _(mo, plot_top3_selection_counts, survey, v_18_8_3):
|
||||
mo.md(f"""
|
||||
### Which 3 voices are chosen the most out of 18?
|
||||
|
||||
How many times does each voice end up in the top 3? ( this is based on the survey question where participants need to choose 3 out of the earlier selected 8 voices. So how often each of the 18 stimuli ended up in participants’ Top 3, after they first selected 8 out of 18.
|
||||
|
||||
{mo.ui.plotly(plot_top3_selection_counts(v_18_8_3, height=500, width=1000))}
|
||||
{mo.ui.plotly(plot_top3_selection_counts(v_18_8_3, height=500, width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
def _(
|
||||
calculate_weighted_ranking_scores,
|
||||
data,
|
||||
mo,
|
||||
plot_ranking_distribution,
|
||||
survey,
|
||||
):
|
||||
def _(calculate_weighted_ranking_scores, data, survey):
|
||||
top3_voices = survey.get_top_3_voices(data)[0].collect()
|
||||
top3_voices_weighted = calculate_weighted_ranking_scores(top3_voices)
|
||||
return top3_voices, top3_voices_weighted
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(mo, plot_ranking_distribution, survey, top3_voices):
|
||||
mo.md(f"""
|
||||
### Which voice is ranked best in the ranking question for top 3?
|
||||
|
||||
(not best 3 out of 8 question)
|
||||
|
||||
{mo.ui.plotly(plot_ranking_distribution(top3_voices, x_label='Voice', width=1000))}
|
||||
|
||||
""")
|
||||
return top3_voices, top3_voices_weighted
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(mo, plot_weighted_ranking_score, top3_voices_weighted):
|
||||
mo.md(f"""
|
||||
### Most popular **voice** based on weighted scores?
|
||||
- E.g. 1 point for place 3. 2 points for place 2 and 3 points for place 1. The voice with most points is ranked best.
|
||||
Distribution of the rankings for each voice:
|
||||
|
||||
{mo.ui.plotly(plot_weighted_ranking_score(top3_voices_weighted, title="Most Popular Voice - Weighted Popularity Score<br>(1st = 3pts, 2nd = 2pts, 3rd = 1pt)", height=500, width=1000))}
|
||||
{mo.ui.plotly(plot_ranking_distribution(top3_voices, x_label='Voice', width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(mo, plot_most_ranked_1, top3_voices):
|
||||
def _(mo, plot_weighted_ranking_score, survey, top3_voices_weighted):
|
||||
mo.md(f"""
|
||||
### Most popular **voice** based on weighted scores?
|
||||
- E.g. 1 point for place 3. 2 points for place 2 and 3 points for place 1. The voice with most points is ranked best.
|
||||
Distribution of the rankings for each voice:
|
||||
|
||||
{mo.ui.plotly(plot_weighted_ranking_score(top3_voices_weighted, title="Most Popular Voice - Weighted Popularity Score<br>(1st = 3pts, 2nd = 2pts, 3rd = 1pt)", height=500, width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(mo, plot_most_ranked_1, survey, top3_voices):
|
||||
mo.md(f"""
|
||||
### Which voice is ranked number 1 the most?
|
||||
|
||||
(not always the voice with most points)
|
||||
|
||||
{mo.ui.plotly(plot_most_ranked_1(top3_voices, title="Most Popular Voice<br>(Number of Times Ranked 1st)", x_label='Voice', width=1000))}
|
||||
{mo.ui.plotly(plot_most_ranked_1(top3_voices, title="Most Popular Voice<br>(Number of Times Ranked 1st)", x_label='Voice', width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return
|
||||
|
||||
@@ -316,7 +313,7 @@ def _(data, survey, utils):
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(mo, pl, plots, ss_long):
|
||||
def _(mo, pl, plots, ss_long, survey):
|
||||
content = """### How does each voice score for each “speaking style labeled trait”?"""
|
||||
|
||||
for i, trait in enumerate(ss_long.select("Description").unique().to_series().to_list()):
|
||||
@@ -325,7 +322,7 @@ def _(mo, pl, plots, ss_long):
|
||||
content += f"""
|
||||
### {i+1}) {trait.replace(":", " ↔ ")}
|
||||
|
||||
{mo.ui.plotly(plots.plot_speaking_style_trait_scores(trait_d, title=trait.replace(":", " ↔ "), height=550))}
|
||||
{mo.ui.plotly(plots.plot_speaking_style_trait_scores(trait_d, title=trait.replace(":", " ↔ "), height=550, results_dir=survey.fig_save_dir))}
|
||||
"""
|
||||
|
||||
mo.md(content)
|
||||
@@ -341,17 +338,20 @@ def _(mo):
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(data, mo, plots, survey):
|
||||
def _(data, survey):
|
||||
vscales = survey.get_voice_scale_1_10(data)[0].collect()
|
||||
# plot_average_scores_with_counts(vscales, x_label='Voice', width=1000)
|
||||
return (vscales,)
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(mo, plots, survey, vscales):
|
||||
mo.md(f"""
|
||||
|
||||
### How does each voice score on a scale from 1-10?
|
||||
|
||||
{mo.ui.plotly(plots.plot_average_scores_with_counts(vscales, x_label='Voice', width=1000))}
|
||||
{mo.ui.plotly(plots.plot_average_scores_with_counts(vscales, x_label='Voice', width=1000, results_dir=survey.fig_save_dir))}
|
||||
""")
|
||||
return (vscales,)
|
||||
return
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
@@ -403,7 +403,7 @@ def _(choice_map, ss_all, utils, vscales):
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(SPEAKING_STYLES, joined_df, mo, plots):
|
||||
def _(SPEAKING_STYLES, joined_df, mo, plots, survey):
|
||||
_content = """### Total Results
|
||||
|
||||
"""
|
||||
@@ -414,11 +414,12 @@ def _(SPEAKING_STYLES, joined_df, mo, plots):
|
||||
df=joined_df,
|
||||
style_color=style,
|
||||
style_traits=traits,
|
||||
title=f"Correlation: Speaking Style {style} and Voice Scale 1-10"
|
||||
title=f"Correlation: Speaking Style {style} and Voice Scale 1-10",
|
||||
results_dir=survey.fig_save_dir
|
||||
)
|
||||
_content += f"""
|
||||
#### Speaking Style **{style}**:
|
||||
|
||||
|
||||
{mo.ui.plotly(fig)}
|
||||
|
||||
"""
|
||||
@@ -469,7 +470,7 @@ def _(mo):
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(SPEAKING_STYLES, df_style, mo, plots, top3_voices, utils):
|
||||
def _(SPEAKING_STYLES, df_style, mo, plots, survey, top3_voices, utils):
|
||||
df_ranking = utils.process_voice_ranking_data(top3_voices)
|
||||
joined = df_style.join(df_ranking, on=['_recordId', 'Voice'], how='inner')
|
||||
|
||||
@@ -479,13 +480,13 @@ def _(SPEAKING_STYLES, df_style, mo, plots, top3_voices, utils):
|
||||
"""
|
||||
|
||||
for _style, _traits in SPEAKING_STYLES.items():
|
||||
_fig = plots.plot_speaking_style_ranking_correlation(joined, _style, _traits)
|
||||
_fig = plots.plot_speaking_style_ranking_correlation(joined, _style, _traits, results_dir=survey.fig_save_dir)
|
||||
_content += f"""
|
||||
|
||||
#### Speaking Style **{_style}**:
|
||||
|
||||
|
||||
{mo.ui.plotly(_fig)}
|
||||
|
||||
|
||||
"""
|
||||
|
||||
mo.md(_content)
|
||||
|
||||
Reference in New Issue
Block a user