<jupyter_start><jupyter_text>Jitter plot<jupyter_code>top10pct_white = white.head(310).reset_index()
top10pct_black = black.head(310).reset_index()
top10pct_indigenous = indigenous.head(310).reset_index()
top10pct_asian = asian.head(310).reset_index()
top10pct_hawaii_PI = hawaii_PI.head(310).reset_index()
top10pct_multi = multi.head(310).reset_index()
data = [top10pct_white["Estimated strongly hesitant"], 
        top10pct_black["Estimated strongly hesitant"], 
        top10pct_indigenous["Estimated strongly hesitant"], 
        top10pct_asian["Estimated strongly hesitant"],
        top10pct_hawaii_PI["Estimated strongly hesitant"],
        top10pct_multi["Estimated strongly hesitant"]]
hesitation = pd.DataFrame(data)
hesitation = hesitation.T
hesitation.columns = ["White", "Black", "Indigenous", "Asian", "Hawaiian or Pacific Islander", "Multi-Racial"]
dfs = []
for i in range(len(data)):
    df = pd.DataFrame(data[i])
    race = hesitation.columns[i]
    df["Race"] = race
    dfs.append(df)
plot_data = pd.concat(dfs)
plot_data.rename({"Estimated strongly hesitant" : "Strong Vaccine Hesitance (Percent)"}, axis=1, inplace=True)
plot_data.head()
fig = plt.figure(figsize=(20, 10))

ax = sns.swarmplot(
    x ="Race", 
    y ="Strong Vaccine Hesitance (Percent)", 
    data = plot_data, 
    palette="Set2",
    edgecolor="gray", 
    alpha=0.25)

median_width = 0.4

for tick, text in zip(ax.get_xticks(), ax.get_xticklabels()):
    sample_name = text.get_text()  # "X" or "Y"

    # calculate the median value for all replicates of either X or Y
    median_val = plot_data[plot_data['Race']==sample_name].mean()

    # plot horizontal lines across the column, centered on the tick
    ax.plot([tick-median_width/2, tick+median_width/2], [median_val, median_val],
            lw=4, color='k', zorder=1)
ax.set_title("Prevalence of Vaccine Hesitancy")
plt.savefig("../images/vax_hesitance_swarm.png")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1391304347826087, 'fraction_numerical': 0.029156010230179028, 'mean_word_length': 4.927272727272728, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '279055', 'license': 'MIT', 'n_tokens_mistral': 764, 'n_tokens_neox': 692, 'n_words': 137, 'path': 'notebooks/HesitancyAnalysis.ipynb', 'repo_name': 'STRIDES-Codes/Supporting-Pandemic-Recovery-Building-insights-on-vaccine-hesitancy-in-the-communities-hardest-hit-', 'size': '1955'}