Add source example files
This commit is contained in:
18
source/plotting/plotly-compose.py
Normal file
18
source/plotting/plotly-compose.py
Normal file
@ -0,0 +1,18 @@
|
||||
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="y", offsetgroup=1),
|
||||
Bar(name="Poids", x=data["product"], y=data["wpu"], yaxis="y2", offsetgroup=2),
|
||||
])
|
||||
# Afficher le dernier graphique généré
|
||||
figure.layout.update({
|
||||
"template": "seaborn",
|
||||
"title": "Prix et poids unitaires", "font": {"family": "Cabin", "size": 13},
|
||||
"yaxis": {"title": "Prix (€)"}, "yaxis2": {"title": "Poids (g)", "overlaying": "y", "side": "right"}
|
||||
})
|
||||
figure.show()
|
Reference in New Issue
Block a user