From 8c55165f69cd2558d1f623c851a6ce64169cb7f1 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 15 Mar 2015 12:36:13 +0100 Subject: [PATCH] =?UTF-8?q?G=C3=A9n=C3=A9ration=20des=20images=20via=20Gnu?= =?UTF-8?q?plot=20via=20Makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- S2/TP4/.gitignore | 2 +- S2/TP4/Makefile | 13 +++++++++++-- S2/TP4/analyse_tris.py | 6 ++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/S2/TP4/.gitignore b/S2/TP4/.gitignore index c6af96f..3e19efc 100644 --- a/S2/TP4/.gitignore +++ b/S2/TP4/.gitignore @@ -1 +1 @@ -tri_insertion_moyen.txt \ No newline at end of file +tri_insertion_moyen.* \ No newline at end of file diff --git a/S2/TP4/Makefile b/S2/TP4/Makefile index c21cd48..70617db 100644 --- a/S2/TP4/Makefile +++ b/S2/TP4/Makefile @@ -1,5 +1,14 @@ -tri_insertion_moyen.txt: analyse_en_moyenne.py +NOM=tri_insertion_moyen +GNUPLOT_EXT=png svg eps +COURBE=0.287*x**2-2*x+1 + +default: $(NOM).png + +$(NOM).txt: analyse_en_moyenne.py python3 $< --brut > $@ +$(addprefix $(NOM).,$(GNUPLOT_EXT)): $(NOM).txt + gnuplot -e "set terminal $(subst $(NOM).,,$@); set output '$(NOM).$(subst $(NOM).,,$@)'; plot '$(NOM).txt', $(COURBE) with lines" + clean: - rm tri_insertion_moyen.txt \ No newline at end of file + rm $(NOM).* \ No newline at end of file diff --git a/S2/TP4/analyse_tris.py b/S2/TP4/analyse_tris.py index f80b48f..d8bc21f 100755 --- a/S2/TP4/analyse_tris.py +++ b/S2/TP4/analyse_tris.py @@ -379,7 +379,9 @@ question(1) reponse("Graphiquement, on trouve que cette fonction a pour expression 0,287 × x² - 2 × x + 1\n\ Cette fonction correspond à la commande suivante : \n\ -gnuplot> plot 'tri_insertion_moyen.txt', 0.287*x**2-2*x +1 with lines\n\ +gnuplot> plot 'tri_insertion_moyen.txt', 0.287*x**2-2*x+1 with lines\n\ On peut aussi trouver des valeurs plus précises en faisant une regression polynôminale des données \ avec la fonction polyfit de numpy. Je vous invite à lancer la commande suivante :\n\ -python3 analyse_en_moyenne.py --brut --poly --graph") +python3 analyse_en_moyenne.py --brut --poly --graph\n\ +Je vous invite aussi à éxecuter la commande suivante qui permet de générer le graphique Gnuplot :\n\ +make tri_insertion_moyen.png")