Enoder commited on
Commit
c29801f
·
verified ·
1 Parent(s): 3d6d83e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -41,9 +41,6 @@ def create_graph(prices_history):
41
  fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(15, 10))
42
  axs = axs.flatten()
43
 
44
- # Pour afficher les prix actuels sous chaque graphique
45
- current_prices = {}
46
-
47
  for ax, (coin, prices) in zip(axs, prices_history.items()):
48
  if prices:
49
  times, price_values = zip(*prices)
@@ -59,16 +56,7 @@ def create_graph(prices_history):
59
  ax.grid()
60
  ax.legend()
61
 
62
- # On récupère le dernier prix de la crypto pour l'afficher en bas
63
- current_prices[coin] = price_values[-1]
64
-
65
- # Ajouter une légende en bas de l'image avec les prix actuels
66
- plt.figtext(0.5, 0.01, 'Prix actuel de chaque crypto-monnaie (en USD):\n', ha='center', fontsize=12)
67
- for i, (coin, price) in enumerate(current_prices.items()):
68
- plt.figtext(0.5, 0.01 - (i + 1) * 0.04, f'{coin.capitalize()}: ${price:.2f}', ha='center', fontsize=10)
69
-
70
  plt.tight_layout()
71
- plt.subplots_adjust(bottom=0.1) # Ajuste le bas pour faire de la place pour la légende
72
  plt.savefig('crypto_prices_rectangle.png')
73
  plt.close()
74
 
@@ -94,6 +82,13 @@ def run_script():
94
 
95
  st.image('crypto_prices_rectangle.png')
96
 
 
 
 
 
 
 
 
97
  st.success("Graphique créé et envoyé à Discord!")
98
 
99
  st.title("Suivi des Prix des Cryptomonnaies")
 
41
  fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(15, 10))
42
  axs = axs.flatten()
43
 
 
 
 
44
  for ax, (coin, prices) in zip(axs, prices_history.items()):
45
  if prices:
46
  times, price_values = zip(*prices)
 
56
  ax.grid()
57
  ax.legend()
58
 
 
 
 
 
 
 
 
 
59
  plt.tight_layout()
 
60
  plt.savefig('crypto_prices_rectangle.png')
61
  plt.close()
62
 
 
82
 
83
  st.image('crypto_prices_rectangle.png')
84
 
85
+ # Affichage des prix actuels sous chaque graphique
86
+ st.write("### Prix actuel des crypto-monnaies :")
87
+ for coin, prices in prices_history.items():
88
+ if prices:
89
+ current_price = prices[-1][1]
90
+ st.write(f"- {coin.capitalize()}: ${current_price:,.2f}")
91
+
92
  st.success("Graphique créé et envoyé à Discord!")
93
 
94
  st.title("Suivi des Prix des Cryptomonnaies")