improved chart style

This commit is contained in:
Faraphel 2024-01-25 15:46:55 +01:00
parent a878d142bd
commit 9967f1dff7
21 changed files with 134 additions and 54 deletions

View file

@ -1,7 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np
from tools.statistics import extract
from tools.statistics import extract, ressource
def analyse(datas: list[dict]) -> plt.Figure:
@ -10,10 +10,12 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Nombre de personne par âge")
axes.set_title("Âge des personnes sondées")
# bar chart
bins = np.arange(min(x), max(x), 1)
axes.hist(x, bins=bins, edgecolor='black')
axes.set_xlabel("Âge")
axes.set_ylabel("Quantité")
return figure

View file

@ -36,5 +36,7 @@ def analyse(datas: list[dict]) -> plt.Figure:
# bar chart
bins = np.arange(min(x), max(x), 1)
axes.hist(x, bins, weights=y, edgecolor="black")
axes.set_xlabel("Âge")
axes.set_ylabel("Complétion")
return figure

View file

@ -29,9 +29,13 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Nombre moyen de mission complété par expérience")
axes.set_title("Nombre moyen de mission complété par opinion")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.experience.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.experience.labels)
axes.set_xlabel("Expérience")
axes.set_ylabel("Complétion")
return figure

View file

@ -1,14 +1,12 @@
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
from tools.statistics import extract
from tools.statistics import extract, ressource
def analyse(datas: list[dict]) -> plt.Figure:
languages_completion: dict[str, int] = defaultdict(lambda: 0)
languages_count: dict[str, int] = defaultdict(lambda: 0)
languages_completion: dict[str, int] = dict.fromkeys(ressource.language.choices, 0)
languages_count: dict[str, int] = dict.fromkeys(ressource.language.choices, 0)
for data in datas:
language = extract.language.extract(data)
@ -34,6 +32,10 @@ def analyse(datas: list[dict]) -> plt.Figure:
axes.set_title("Nombre moyen de mission complété par langue")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.language.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.language.labels)
axes.set_xlabel("Langue")
axes.set_ylabel("Complétion")
return figure

View file

@ -23,11 +23,14 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Nombre de personne ayant réussi par mission")
axes.set_title("Nombre de mission total complété")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.mission.colors, edgecolor='black')
axes.set_xlabel("Mission")
axes.set_ylabel("Complétion")
axes.set_xticks(x)
axes.set_xticklabels(x, rotation=45)
axes.set_xticklabels(ressource.mission.labels, rotation=45, ha="right")
figure.tight_layout()
return figure

View file

@ -33,9 +33,13 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Nombre moyen de mission complété par niveau")
axes.set_title("Nombre moyen de mission complété par habitude d'utilisation")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.usage.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.usage.labels)
axes.set_xlabel("Usage")
axes.set_ylabel("Complétion")
return figure

View file

@ -37,5 +37,7 @@ def analyse(datas: list[dict]) -> plt.Figure:
# bar chart
bins = np.arange(min(x), max(x), 1)
axes.hist(x, bins, weights=y, edgecolor="black")
axes.set_xlabel("Âge")
axes.set_ylabel("Durée")
return figure

View file

@ -29,9 +29,13 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Temps moyen passé par expérience")
axes.set_title("Temps moyen passé par opinion")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.experience.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.experience.labels)
axes.set_xlabel("Expérience")
axes.set_ylabel("Durée")
return figure

View file

@ -1,14 +1,12 @@
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
from tools.statistics import extract
from tools.statistics import extract, ressource
def analyse(datas: list[dict]) -> plt.Figure:
languages_duration: dict[str, int] = defaultdict(lambda: 0)
languages_count: dict[str, int] = defaultdict(lambda: 0)
languages_duration: dict[str, int] = dict.fromkeys(ressource.language.choices, 0)
languages_count: dict[str, int] = dict.fromkeys(ressource.language.choices, 0)
for data in datas:
language = extract.language.extract(data)
@ -33,6 +31,10 @@ def analyse(datas: list[dict]) -> plt.Figure:
axes.set_title("Temps moyen passé par langue")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.language.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.language.labels)
axes.set_xlabel("Langue")
axes.set_ylabel("Durée")
return figure

View file

@ -24,11 +24,14 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Temps moyen passé par test")
axes.set_title("Temps total passé par mission")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.mission.colors, edgecolor='black')
axes.set_xlabel("Mission")
axes.set_ylabel("Durée")
axes.set_xticks(x)
axes.set_xticklabels(x, rotation=45)
axes.set_xticklabels(ressource.mission.labels, rotation=45, ha="right")
figure.tight_layout()
return figure

View file

@ -28,9 +28,13 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Temps moyen passé par niveau")
axes.set_title("Temps moyen passé par habitude d'utilisation")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.usage.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.usage.labels)
axes.set_xlabel("Usage")
axes.set_ylabel("Durée")
return figure

View file

@ -18,9 +18,13 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Nombre de personne par expérience")
axes.set_title("Opinion des personnes sondées")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.experience.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.experience.labels)
axes.set_xlabel("Expérience")
axes.set_ylabel("Quantité")
return figure

View file

@ -18,8 +18,11 @@ def analyse(datas: list[dict]) -> plt.Figure:
axes.set_title("Mission la plus difficile des personnes sondées")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.mission.colors, edgecolor='black')
axes.set_xlabel("Mission")
axes.set_ylabel("Quantité")
axes.set_xticks(x)
axes.set_xticklabels(x, rotation=45)
axes.set_xticklabels(ressource.mission.labels, rotation=45, ha="right")
figure.tight_layout()
return figure

View file

@ -1,16 +1,15 @@
from collections import Counter
import matplotlib.pyplot as plt
from tools.statistics import extract
from tools.statistics import extract, ressource
def analyse(datas: list[dict]) -> plt.Figure:
languages = list(map(extract.language.extract, datas))
languages = dict.fromkeys(ressource.language.choices, 0)
for language in map(extract.language.extract, datas):
languages[language] += 1
counter = Counter(languages)
x = list(counter.keys())
y = list(counter.values())
x = list(languages.keys())
y = list(languages.values())
# prepare plotting
figure: plt.Figure = plt.figure()
@ -18,6 +17,10 @@ def analyse(datas: list[dict]) -> plt.Figure:
axes.set_title("Langue des personnes sondées")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.language.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.language.labels)
axes.set_xlabel("Langue")
axes.set_ylabel("Quantité")
return figure

View file

@ -4,10 +4,8 @@ from tools.statistics import extract, ressource
def analyse(datas: list[dict]) -> plt.Figure:
usage_data = list(map(extract.usage.extract, datas))
usages: dict[str, int] = dict.fromkeys(ressource.usage.choices, 0)
for usage in usage_data:
for usage in map(extract.usage.extract, datas):
usages[usage] += 1
x = list(usages.keys())
@ -16,9 +14,11 @@ def analyse(datas: list[dict]) -> plt.Figure:
# prepare plotting
figure: plt.Figure = plt.figure()
axes = figure.add_subplot(1, 1, 1)
axes.set_title("Expérience antérieure des personnes sondées")
axes.set_title("Habitude d'utilisation des personnes sondées")
# bar chart
axes.bar(x, y, edgecolor='black')
axes.bar(x, y, color=ressource.usage.colors, edgecolor='black')
axes.set_xticks(x)
axes.set_xticklabels(ressource.usage.labels)
return figure

View file

@ -1,22 +1,28 @@
from pathlib import Path
from matplotlib import pyplot as plt
from tools.statistics.analyse import (age, usage, completion_per_mission, duration_per_mission, completion_per_age,
completion_per_usage, duration_per_age, duration_per_usage,
completion_per_experience, duration_per_experience, experience, hardest_mission,
language, duration_per_language, completion_per_language)
plt.rcParams['text.usetex'] = True
if __name__ == "__main__":
from source.utils import compress
# import matplotlib
# matplotlib.use("pgf")
# matplotlib.rcParams.update({
# "pgf.texsystem": "pdflatex",
# 'font.family': 'serif',
# 'font.size': 11,
# 'text.usetex': True,
# 'pgf.rcfonts': False,
# })
import matplotlib
matplotlib.use("pgf")
matplotlib.rcParams.update({
"pgf.texsystem": "pdflatex",
'font.family': 'serif',
'font.size': 11,
'text.usetex': True,
'pgf.rcfonts': False,
})
sondage_path = Path(r"./sondage/")
graph_path = Path(r"./graph/")

View file

@ -1,3 +1,4 @@
from . import experience
from . import mission
from . import usage
from . import language

View file

@ -1 +1,3 @@
choices = ["yes", "mixed", "no"]
labels = ["Oui", "Mitigé", "Non"]
colors = ["g", "y", "r"]

View file

@ -0,0 +1,3 @@
choices = ["fr", "en", "es"]
labels = ["Français", "Anglais", "Espagnol"]
colors = ["b", "g", "r"]

View file

@ -10,3 +10,27 @@ choices = [
"mission-gift-card",
"mission-workshop",
]
labels = [
"Changement de Langue",
"Filtre de Prix",
"Hub de la Communauté",
"Page de Jeu",
"Page de DLC",
"Page d'Actualité",
"Page de Profil",
"Page de Discussion",
"Carte Cadeaux",
"Workshop",
]
colors = [
"tab:blue",
"tab:orange",
"tab:green",
"tab:red",
"tab:olive",
"tab:purple",
"tab:brown",
"tab:pink",
"tab:cyan",
"tab:gray",
]

View file

@ -1 +1,3 @@
choices = ["always", "often", "sometime", "rarely", "never"]
labels = ["Toujours", "Souvent", "Parfois", "Rarement", "Jamais"]
colors = ["g", "c", "y", "m", "r"]