Skip to content

Instantly share code, notes, and snippets.

@Stormix
Created April 18, 2017 12:35
Show Gist options
  • Save Stormix/346a40ce4e512107f09f458c95246188 to your computer and use it in GitHub Desktop.
Save Stormix/346a40ce4e512107f09f458c95246188 to your computer and use it in GitHub Desktop.
Programme pour créer des graphes en python (Par Anas Mazouni)
#!/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 ! ✔')
@Stormix
Copy link
Author

Stormix commented Apr 18, 2017

Avant d'exécuter , il faut installer :

  • Slugify : pip install slugify

  • Matplotlib : pip install matplotlib

  • Numpy : pip install numpy

Good Luck 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment