# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt

import matplotlib
matplotlib.rcParams['mathtext.fontset'] = 'stix'
matplotlib.rcParams['font.family'] = 'STIXGeneral'


#%% FONCTION

def f(x, alpha=0.5,io=0.01,Eth=0): #le "C=1", il fait que si tu précises rien, genre "f(3)", il prend par défaut C=1
    
    return io*np.exp(alpha*10000/300*(x-Eth))


#LISTE DES X
X = np.linspace(-1,1,1000) #début, fin, nombre de points

#LISTE DES Y
Y1 = f(X, alpha=0.5, io=0.2)
Y2 = f(X, alpha=-0.5, io=-0.2)
Y3 = Y1 + Y2

#%% GRAPHE

fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111)

ax.set_xlim(-.25,.25) #Limites de l'axe X
ax.set_ylim(-.25,.25) #Limites de l'axe Y

ax.set_xlabel(r'$x$', fontsize = 20) #Titre axe X
ax.set_ylabel(r'$q/q_m$', fontsize = 20) #Titre axe Y


ax.plot(X,Y1, label=r'courant anodique', lw=4) #label : nom dans la légende, lw : épaisseur du trait

ax.plot(X,Y2, label=r'courant cathodique', lw=4) #label : nom dans la légende, lw : épaisseur du trait

ax.plot(X,Y3, label=r'courant echange', lw=4) 

#%% OPTIONNEL

ax.grid(True) #Grille
ax.legend(loc=2 ,prop={'size':15}) #Legende


