Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
|
| 5 |
+
# Définition des fonctions
|
| 6 |
+
def f_annees(x):
|
| 7 |
+
return 466.01 * x**3 - 9159.67 * x**2 + 53510.68 * x - 18021.21
|
| 8 |
+
|
| 9 |
+
def f_heures(x):
|
| 10 |
+
return -95.62 * x**3 + 1255.59 * x**2 - 2711.48 * x + 84622.22
|
| 11 |
+
|
| 12 |
+
def f_jours(x):
|
| 13 |
+
return 0.577 * x**3 - 12.16 * x**2 - 50.00 * x + 94941.27
|
| 14 |
+
|
| 15 |
+
# Fonction pour générer les graphiques
|
| 16 |
+
def plot_graph(func, title):
|
| 17 |
+
x = np.linspace(0, 60, 500)
|
| 18 |
+
y = func(x)
|
| 19 |
+
|
| 20 |
+
plt.figure(figsize=(10,6))
|
| 21 |
+
plt.plot(x, y, label=f'{title}', color='b')
|
| 22 |
+
plt.title(f'Graphique: {title}')
|
| 23 |
+
plt.xlabel('x')
|
| 24 |
+
plt.ylabel('f(x)')
|
| 25 |
+
plt.grid(True)
|
| 26 |
+
plt.legend()
|
| 27 |
+
st.pyplot(plt)
|
| 28 |
+
|
| 29 |
+
# Interface Streamlit
|
| 30 |
+
st.title('Générateur de Graphiques')
|
| 31 |
+
|
| 32 |
+
st.write("""
|
| 33 |
+
Sélectionnez une fonction pour afficher son graphique.
|
| 34 |
+
""")
|
| 35 |
+
|
| 36 |
+
# Choisir le type de données
|
| 37 |
+
option = st.selectbox(
|
| 38 |
+
'Choisissez un type de données',
|
| 39 |
+
('Données annuelles', 'Données hebdomadaires', 'Données journalières')
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
if option == 'Données annuelles':
|
| 43 |
+
plot_graph(f_annees, 'Données annuelles (f(x) = 466.01x³ - 9159.67x² + 53510.68x - 18021.21)')
|
| 44 |
+
elif option == 'Données hebdomadaires':
|
| 45 |
+
plot_graph(f_heures, 'Données hebdomadaires (f(x) = -95.62x³ + 1255.59x² - 2711.48x + 84622.22)')
|
| 46 |
+
else:
|
| 47 |
+
plot_graph(f_jours, 'Données journalières (f(x) = 0.577x³ - 12.16x² - 50.00x + 94941.27)')
|