21 lines
800 B
Python
21 lines
800 B
Python
import pandas as pd
|
|
from plotly.graph_objs import Figure, Bar
|
|
|
|
data = pd.DataFrame(data={
|
|
"product": ["pomme", "poire", "banane", "pêche"],
|
|
"price": [1.99, 2.49, 2.99, 3.49], "wpu": [200, 180, 140, 200]
|
|
})
|
|
figure = Figure([
|
|
Bar(name="Prix", x=data["product"], y=data["price"], yaxis="y1", offsetgroup=1, texttemplate="%{y:.2f}€"),
|
|
Bar(name="Poids", x=data["product"], y=data["wpu"], yaxis="y2", offsetgroup=2, texttemplate="%{y:.2f}g"),
|
|
])
|
|
# Afficher le dernier graphique généré
|
|
figure.layout.update({
|
|
"template": "seaborn",
|
|
"title": "Prix et poids unitaires",
|
|
"font": {"family": "Cabin", "size": 13},
|
|
"yaxis1": {"title": "Prix (€)", "color": "red"},
|
|
"yaxis2": {"title": "Poids (g)", "overlaying": "y1", "side": "right"}
|
|
})
|
|
figure.show(renderer="browser")
|