Created
April 18, 2017 12:35
-
-
Save Stormix/346a40ce4e512107f09f458c95246188 to your computer and use it in GitHub Desktop.
Programme pour créer des graphes en python (Par Anas Mazouni)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from slugify import slugify | |
import random | |
colors = ['b','g','r','m','y','c'] | |
x = [] # ex : [0,1,2,3,4] | |
y = [] # ex : [0,1,2,3,4] | |
xlabel = '' # ex : 'Axe des X' | |
ylabel = '' # ex : 'Axe des Y' | |
title = '' # ex : 'Titre du graphe' | |
assert len(x) == len(y), "Taille des X != Taille des Y" | |
plt.plot(np.array(x), np.array(y),color = random.choice(colors)) | |
plt.xlabel(xlabel.decode("utf8")) | |
plt.ylabel(ylabel.decode("utf8")) | |
plt.title(title.decode("utf8")) | |
plt.grid(True) | |
plt.savefig("graphes/"+slugify(unicode(title.decode("utf8")))+".png") | |
print('Graphe Crée ! ✔') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Avant d'exécuter , il faut installer :
Slugify :
pip install slugify
Matplotlib :
pip install matplotlib
Numpy :
pip install numpy
Good Luck 👍