Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # yes i know my code sucks shut up
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- # ---------------------------------------------------------------------------------------------------------------
- # Define some things I'm going to use later.
- colors = ['#7f7f7f', '#315feb', '#c83940', '#a55ba8', '#07975b',
- '#34a416', '#9eceb9', '#e3d8e4', '#f58fef', '#e9a958',
- '#106520', '#c30041', '#d106ad', '#26facd', '#5665e6',
- '#621b5c', '#a50c68', '#d2ed28', '#d7b91f']
- def unpack(x):
- y = []
- for i in x:
- if isinstance(i, list):
- y.extend(i)
- else:
- y.append(i)
- return y
- # ---------------------------------------------------------------------------------------------------------------
- # Load data.
- df = pd.read_csv(r'C:\Users\Mathe\OneDrive\Documents\AsrielUndertale Survey.csv')
- df = df.drop(columns='Carimbo de data/hora')
- # ---------------------------------------------------------------------------------------------------------------
- # Fix some of the answers and parse results.
- df['What is your sexual orientation?'].iloc[33] = 'Unsure'
- df['What country are you from?'].iloc[[0, 2, 3, 6, 7, 10, 13, 16, 25, 29, 32, 33, 35, 36, 38, 40, 43, 46, 47, 56, 58]] = 'USA'
- df['What country are you from?'].iloc[[20, 23, 30, 57, 61]] = ['Canada', 'Australia', 'UK', np.nan, 'Netherlands']
- df['What is your religious status?'].iloc[[10, 16, 47, 48, 59]] = ['Unsure', 'Unsure', 'Asriel', 'Asriel', 'Unsure']
- df['What is your favorite song from Undertale?'].iloc[3] = 'Hopes and Dreams'
- df['What Undertale AUs have you played/watched/read?'].iloc[[3, 5, 11, 23, 30, 53, 58]] = ['Glitchtale',
- np.nan,
- 'Glitchtale;Handplates;Undertale green;Unexpected guests;Sooner or Later You\'re Gonna be Mine;A Thorn In My Side',
- 'Dreemurr Reborn;Endertale;Growth Spurt',
- 'Dreemurr Reborn;Over The Void;Half-Hearted Dreamers;Growth Spurt',
- 'Dreemurr Reborn;Storyshift;Underfell;Growth Spurt',
- 'Glitchtale;Inverted Fate;Storyshift;Swaptale;Taletwist;Underfell;Underswap;Revenge - The Unseen Ending']
- df['What Undertale AUs have you played/watched/read?'] = df['What Undertale AUs have you played/watched/read?'].apply(lambda x: x if x is np.nan else x.split(';'))
- df['What Deltarune AUs have you played/watched/read?'] = df['What Deltarune AUs have you played/watched/read?'].apply(lambda x: x.replace('Nudealrt', 'Nudealert') if x is not np.nan else np.nan) # I mistyped it lol.
- df['What Deltarune AUs have you played/watched/read?'].iloc[[2, 5, 11, 52, 54, 59]] = ['Nudealert/Deltarune repainted;Paper Trail',
- np.nan,
- 'Paper Trail',
- 'Paper Trail',
- np.nan,
- 'Horrorrune;Paper Trail']
- df['What Deltarune AUs have you played/watched/read?'] = df['What Deltarune AUs have you played/watched/read?'].apply(lambda x: x if x is np.nan else x.split(';'))
- df['What other Undertale/Deltarune related subreddits do you participate in?'].iloc[[11, 23, 58]] = ['Charadefensesquad;Undertale;Asriel_Defence_Squad',
- 'AsgoreDefenseSquad;Charadefensesquad;Deltarune;fluffyboi;ralsei;RalseiWithGuns;Asriel_Defence_Squad',
- 'fluffyboi']
- df['What other Undertale/Deltarune related subreddits do you participate in?'] = df['What other Undertale/Deltarune related subreddits do you participate in?'].apply(lambda x: x if x is np.nan else x.split(';'))
- df['Which of these do you think best describe Asriel?'] = df['Which of these do you think best describe Asriel?'].apply(lambda x: x if x is np.nan else x.split(';'))
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your biological sex?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, 0))
- plt.title('What is your biological sex?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your biological sex?'].fillna('Didn\'t answer'), return_counts=True)
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, 0))
- plt.title('What is your biological sex?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What gender do you identify as?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, -.1))
- plt.title('What gender do you identify as?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What gender do you identify as?'].fillna('Didn\'t answer'), return_counts=True)
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, -.1))
- plt.title('What gender do you identify as?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your sexual orientation?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, -.3))
- plt.title('What is your sexual orientation?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your sexual orientation?'].fillna('Didn\'t answer'), return_counts=True)
- x = [[x[0][3], *x[0][:3], *x[0][4:]], [x[1][3], *x[1][:3], *x[1][4:]]]
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, -.3))
- plt.title('What is your sexual orientation?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your age?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('What is your age?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your age?'].fillna('Didn\'t answer'), return_counts=True)
- x = [[x[0][-1], *x[0][:-1]], [x[1][-1], *x[1][:-1]]]
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .05))
- plt.title('What is your age?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What country are you from?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, -.3))
- plt.title('What country are you from?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What country are you from?'].fillna('Didn\'t answer'), return_counts=True)
- x = [[x[0][4], *x[0][:4], *x[0][5:]], [x[1][4], *x[1][:4], *x[1][5:]]]
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, -.4))
- plt.title('What country are you from?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your religious status?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('What is your religious status?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your religious status?'].fillna('Didn\'t answer'), return_counts=True)
- x = [[x[0][5], *x[0][:5], *x[0][6:]], [x[1][5], *x[1][:5], *x[1][6:]]]
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('What is your religious status?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Do you consider yourself an anime fan?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('Do you consider yourself an anime fan?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Do you consider yourself an anime fan?'].fillna('Didn\'t answer'), return_counts=True)
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('Do you consider yourself an anime fan?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Do you consider yourself a furry?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('Do you consider yourself a furry?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Do you consider yourself a furry?'].fillna('Didn\'t answer'), return_counts=True)
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('Do you consider yourself a furry?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What led you to join the subreddit?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('What led you to join the subreddit?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What led you to join the subreddit?'].fillna('Didn\'t answer'), return_counts=True)
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.95, .08))
- plt.title('What led you to join the subreddt?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- fig, ax = plt.subplots(figsize=(9, 4))
- data = df['What was your score for Extroversion?'].dropna()
- ax.hist(data, 100)
- ax.xaxis.set_ticks(range(0, 105, 5))
- plt.title('What was your score for Extroversion? (50 answers)')
- plt.show()
- print('Mean: ', round(data.mean(), 1))
- print('Median: ', data.median())
- # ---------------------------------------------------------------------------------------------------------------
- fig, ax = plt.subplots(figsize=(9, 4))
- data = df['What was your score for Emotional Stability?'].dropna()
- ax.hist(data, 100)
- ax.xaxis.set_ticks(range(0, 105, 5))
- ax.yaxis.set_ticks(range(7))
- ax.set_ylim(0, 6.3)
- plt.title('What was your score for Emotional Stability? (50 answers)')
- plt.show()
- print('Mean: ', round(data.mean(), 1))
- print('Median: ', data.median())
- # ---------------------------------------------------------------------------------------------------------------
- fig, ax = plt.subplots(figsize=(9, 4))
- data = df['What was your score for Agreeableness?'].dropna()
- ax.hist(data, 100)
- ax.xaxis.set_ticks(range(0, 105, 5))
- plt.title('What was your score for Agreeableness? (48 answers)')
- plt.show()
- print('Mean: ', round(data.mean(), 1))
- print('Median: ', data.median())
- # ---------------------------------------------------------------------------------------------------------------
- fig, ax = plt.subplots(figsize=(9, 4))
- data = df['What was your score for Conscientiousness?'].dropna()
- ax.hist(data, 100)
- ax.xaxis.set_ticks(range(0, 105, 5))
- ax.yaxis.set_ticks(range(7))
- ax.set_ylim(0, 6.3)
- plt.title('What was your score for Conscientiousness? (50 answers)')
- plt.show()
- print('Mean: ', round(data.mean(), 1))
- print('Median: ', data.median())
- # ---------------------------------------------------------------------------------------------------------------
- fig, ax = plt.subplots(figsize=(9, 4))
- data = df['What was your score for Intellect/Imagination?'].dropna()
- ax.hist(data, 100)
- ax.xaxis.set_ticks(range(0, 105, 5))
- plt.title('What was your score for Intellect/Imagination? (48 answers)')
- plt.show()
- print('Mean: ', round(data.mean(), 1))
- print('Median: ', data.median())
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Have you ever played Undertale yourself?'], return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, 0))
- plt.title('Have you ever played Undertale yourself?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Have you ever played Deltarune yourself?'], return_counts=True)
- plot = plt.pie(x[1], colors=['#a55ba8', '#315feb', '#c83940'])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(.9, 0))
- plt.title('Have you ever played Deltarune yourself?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- def autolabel(rects, i):
- for rect in rects:
- height = rect.get_height()
- ax[i].annotate('{}'.format(height),
- xy=(rect.get_x() + rect.get_width() / 2, height),
- xytext=(0, 3), # 3 points vertical offset
- textcoords="offset points",
- ha='center', va='bottom')
- routes = ('Pacifist', 'Neutral', 'Genocide')
- fig, ax = plt.subplots(1, 3, figsize=(18, 4))
- x = ['0', '1', '2', '3', '4', '5+']
- for i in range(3):
- route = routes[i]
- y = (len(np.where(df['If you have played Undertale yourself, how many times have you completed each of the routes? [{}]'.format(route)].dropna() == '0')[0]),\
- len(np.where(df['If you have played Undertale yourself, how many times have you completed each of the routes? [{}]'.format(route)].dropna() == '1')[0]),\
- len(np.where(df['If you have played Undertale yourself, how many times have you completed each of the routes? [{}]'.format(route)].dropna() == '2')[0]),\
- len(np.where(df['If you have played Undertale yourself, how many times have you completed each of the routes? [{}]'.format(route)].dropna() == '3')[0]),\
- len(np.where(df['If you have played Undertale yourself, how many times have you completed each of the routes? [{}]'.format(route)].dropna() == '4')[0]),\
- len(np.where(df['If you have played Undertale yourself, how many times have you completed each of the routes? [{}]'.format(route)].dropna() == '5+')[0]))
- rects = ax[i].bar(x, y, width=.6, color=colors[1:])
- autolabel(rects, i)
- ax[i].set_title('{} ({} answers)'.format(route, sum(y)))
- ax[i].set_ylim(0, 32)
- fig.suptitle('If you have played Undertale yourself, how many times have you completed each of the routes?', y=1.1)
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- def autolabel(rects):
- for rect in rects:
- height = int(rect.get_height())
- ax.annotate('{}'.format(height),
- xy=(rect.get_x() + rect.get_width() / 2, height),
- xytext=(0, 3), # 3 points vertical offset
- textcoords="offset points",
- ha='center', va='bottom')
- fig, ax = plt.subplots(figsize=(7, 4))
- data = np.array(df['What would you rate Undertale on a scale from 0 - 10?'].dropna()).astype('int32')
- data = np.array([len(np.where(data == i)[0]) for i in range(11)])
- rects = ax.bar(range(11), data, width=.6)
- ax.set_xticks(range(11))
- ax.set_xlim(-.5, 10.5)
- ax.set_ylim(0, 33)
- autolabel(rects)
- plt.title('What would you rate Undertale on a scale from 0 - 10? (62 answers)')
- plt.show()
- print('Mean: ', round((range(11)*data).sum()/data.sum(), 1))
- # ---------------------------------------------------------------------------------------------------------------
- def autolabel(rects):
- for rect in rects:
- height = int(rect.get_height())
- ax.annotate('{}'.format(height),
- xy=(rect.get_x() + rect.get_width() / 2, height),
- xytext=(0, 3), # 3 points vertical offset
- textcoords="offset points",
- ha='center', va='bottom')
- fig, ax = plt.subplots(figsize=(7, 4))
- data = np.array(df['What would you rate Deltarune on a scale from 0 - 10?'].dropna()).astype('int32')
- data = np.array([len(np.where(data == i)[0]) for i in range(11)])
- rects = ax.bar(range(11), data, width=.6)
- ax.set_xticks(range(11))
- ax.set_xlim(-.5, 10.5)
- ax.set_ylim(0, 33)
- autolabel(rects)
- plt.title('What would you rate Deltarune on a scale from 0 - 10? (60 answers)')
- plt.show()
- print('Mean: ', round((range(11)*data).sum()/data.sum(), 1))
- # ---------------------------------------------------------------------------------------------------------------
- def autolabel(rects, i, j):
- """Attach a text label above each bar in *rects*, displaying its height."""
- for rect in rects:
- height = rect.get_height()
- ax[i,j].annotate('{}'.format(height),
- xy=(rect.get_x() + rect.get_width() / 2, height),
- xytext=(0, 3), # 3 points vertical offset
- textcoords="offset points",
- ha='center', va='bottom')
- labels = ['Hate', 'Dislike', 'Neutral', 'Like', 'Love']
- characters = ['Alphys', 'Asgore', 'Asriel', 'Chara', 'Flowey', 'Frisk', 'Jevil', 'King', 'Kris',
- 'Lancer', 'Mettaton', 'Muffet', 'Papyrus', 'Ralsei', 'Rouxls Kaard', 'Sans',
- 'Susie', 'Toriel', 'Undyne']
- x = np.arange(5)
- fig, ax = plt.subplots(4, 5, figsize=(30, 20))
- for i in range(len(characters)):
- c = characters[i]
- counts = [len(np.where(df['How much do you like/dislike the following characters from the franchise? [{}]'.format(c)] == 'Hate')[0]),
- len(np.where(df['How much do you like/dislike the following characters from the franchise? [{}]'.format(c)] == 'Dislike')[0]),
- len(np.where(df['How much do you like/dislike the following characters from the franchise? [{}]'.format(c)] == 'Neutral')[0]),
- len(np.where(df['How much do you like/dislike the following characters from the franchise? [{}]'.format(c)] == 'Like')[0]),
- len(np.where(df['How much do you like/dislike the following characters from the franchise? [{}]'.format(c)] == 'Love')[0])]
- rects = ax[i//5,i%5].bar(x, counts, width=.5, label=c, color=['red', 'orange', 'green', 'blue', 'purple'])
- autolabel(rects, i//5, i%5)
- ax[i//5,i%5].set_title(c)
- ax[i//5,i%5].set_xticks(x)
- ax[i//5,i%5].set_xticklabels(labels)
- ax[i//5,i%5].set_ylim(0, 59)
- fig.delaxes(ax[-1,-1])
- fig.suptitle('How much do you like/dislike the following characters from the franchise?', x=.51, y=.95, fontsize=20)
- plt.subplots_adjust(hspace=.5)
- plt.show()
- print('Most beloved character: Asriel')
- print('Most disliked character: King')
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['And who is your favorite character overall?'], return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, .13))
- plt.title('And who is your favorite character overall?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your favorite song from Undertale?'], return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, -.2))
- plt.title('What is your favorite song from Undertale?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your favorite song from Deltarune?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, -.3))
- plt.title('What is your favorite song from Deltarune?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['What is your favorite song from Deltarune?'].fillna('Didn\'t answer'), return_counts=True)
- x = [[x[0][6], *x[0][:6], *x[0][7:]], [x[1][6], *x[1][:6], *x[1][7:]]]
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, -.4))
- plt.title('What is your favorite song from Deltarune?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Which do you think is the hardest boss fight?'].dropna(), return_counts=True)
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, -.2))
- plt.title('Which do you think is the hardest boss fight?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = np.unique(df['Which do you think is the hardest boss fight?'].fillna('Didn\'t answer'), return_counts=True)
- x = [[x[0][1], *x[0][:1], *x[0][2:]], [x[1][1], *x[1][:1], *x[1][2:]]]
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, -.3))
- plt.title('Which do you think is the hardest boss fight?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- data = unpack(df['What Undertale AUs have you played/watched/read?'].fillna('None/Didn\'t answer'))
- x = np.unique(data, return_counts=True)
- x = [[x[0][20], *x[0][:20], *x[0][21:]], [x[1][20], *x[1][:20], *x[1][21:]]]
- total = 63
- fig, ax = plt.subplots(figsize=(7, 11))
- ax.set_xlim(right=36)
- rects = ax.barh(range(len(x[0])), x[1], .6, tick_label=x[0])
- for rect in rects:
- width = int(rect.get_width())
- xloc = 5
- yloc = rect.get_y() + rect.get_height() / 2
- label = '({} | {}%)'.format(width, str(round(width/total*100, 1)))
- ax.annotate(label, xy=(width, yloc), xytext=(xloc, 0),
- textcoords="offset points",
- va='center', ha='left', clip_on=True)
- plt.title('What Undertale AUs have you played/watched/read?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- data = unpack(df['What Deltarune AUs have you played/watched/read?'].fillna('None/Didn\'t answer'))
- x = np.unique(data, return_counts=True)
- x = [[x[0][2], *x[0][:2], *x[0][3:]], [x[1][2], *x[1][:2], *x[1][3:]]]
- total = 63
- fig, ax = plt.subplots(figsize=(7, 2))
- ax.set_xlim(right=60)
- rects = ax.barh(range(len(x[0])), x[1], .5, tick_label=x[0])
- for rect in rects:
- width = int(rect.get_width())
- xloc = 5
- yloc = rect.get_y() + rect.get_height() / 2
- label = '({} | {}%)'.format(width, str(round(width/total*100, 1)))
- ax.annotate(label, xy=(width, yloc), xytext=(xloc, 0),
- textcoords="offset points",
- va='center', ha='left', clip_on=True)
- plt.title('What Deltarune AUs have you played/watched/read?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- data = unpack(df['What other Undertale/Deltarune related subreddits do you participate in?'].fillna('None/Didn\'t answer'))
- x = np.unique(data, return_counts=True)
- x = [[x[0][11], *x[0][:11], *x[0][12:]], [x[1][11], *x[1][:11], *x[1][12:]]]
- total = 63
- fig, ax = plt.subplots(figsize=(7, 10))
- ax.set_xlim(right=47)
- rects = ax.barh(range(len(x[0])), x[1], .6, tick_label=x[0])
- for rect in rects:
- width = int(rect.get_width())
- xloc = 5
- yloc = rect.get_y() + rect.get_height() / 2
- label = '({} | {}%)'.format(width, str(round(width/total*100, 1)))
- ax.annotate(label, xy=(width, yloc), xytext=(xloc, 0),
- textcoords="offset points",
- va='center', ha='left', clip_on=True)
- plt.title('What other Undertale/Deltarune related subreddits do you participate in?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = list(np.unique(df['How much do you like Asriel?'].dropna(), return_counts=True))
- x[0], x[1] = [*x[0][1:4], x[0][0], *x[0][4:]], [*x[1][1:4], x[1][0], *x[1][4:]]
- plot = plt.pie(x[1], colors=colors[1:])
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, -.2))
- plt.title('How much do you like Asriel?')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- x = list(np.unique(df['How much do you like Asriel?'].fillna('Didn\'t answer'), return_counts=True))
- x[0], x[1] = [*x[0][1:4], x[0][0], *x[0][4:]], [*x[1][1:4], x[1][0], *x[1][4:]]
- x[0], x[1] = [x[0][4], *x[0][:4], *x[0][5:]], [x[1][4], *x[1][:4], *x[1][5:]]
- plot = plt.pie(x[1], colors=colors)
- total = sum(x[1])
- legends = [x[0][i]+' ({} | {}%)'.format(str(x[1][i]), str(round(x[1][i]/total*100, 1))) for i in range(len(x[0]))]
- plt.legend(plot[0], legends, loc=(1, -.2))
- plt.title('How much do you like Asriel?\n(With empty answers)')
- plt.show()
- # ---------------------------------------------------------------------------------------------------------------
- data = unpack(df['Which of these do you think best describe Asriel?'])
- x = np.unique(data, return_counts=True)
- x[0][0], x[0][1] = x[0][1], x[0][0]
- x[1][0], x[1][1] = x[1][1], x[1][0]
- total = 63
- fig, ax = plt.subplots(figsize=(7, 4))
- ax.set_xlim(right=55)
- rects = ax.barh(range(len(x[0])), x[1], .5, tick_label=x[0])
- for rect in rects:
- width = int(rect.get_width())
- xloc = 5
- yloc = rect.get_y() + rect.get_height() / 2
- label = '({} | {}%)'.format(width, str(round(width/total*100, 1)))
- ax.annotate(label, xy=(width, yloc), xytext=(xloc, 0),
- textcoords="offset points",
- va='center', ha='left', clip_on=True)
- plt.title('Which of these do you think best describe Asriel?')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement