Created
September 17, 2022 16:40
-
-
Save RedBlaze42/943caa2ba6bd51ca6064be2bdb80bdbc to your computer and use it in GitHub Desktop.
Tutoriel plotly
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
import plotly.express as px | |
from datetime import datetime | |
dates_str = ["21/07/1998", "21/08/1998", "21/09/1998", "21/10/1998", "21/11/1998", "21/12/1998"] # X | |
valeurs = [1, 2, 3, 3, 2, 1] # Y | |
# %d = jour du mois 00-31 | |
# %m = mois de l'année 00-12 | |
# %Y = année en 4 chiffres 0000-9999 | |
format_date = "%d/%m/%Y" | |
# Conversion texte vers dates | |
dates = list() | |
for date_str in dates_str: | |
date = datetime.strptime(date_str, format_date) # conversion chaîne de caractère vers objet date | |
dates.append(date) # ajout de la date convertie dans la liste | |
fig = px.line(x=dates, y=valeurs) # création du graphique | |
fig.show() # affichage du graphique dans le navigateur |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment