2025.44 changes
This commit is contained in:
30
source/plotting/charts/plotly_trace_image.py
Normal file
30
source/plotting/charts/plotly_trace_image.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import pandas as pd
|
||||
from plotly.graph_objs import Figure, Bar
|
||||
from PIL import Image
|
||||
|
||||
data = pd.DataFrame(
|
||||
data={
|
||||
"product": ["tarte", "gâteau", "biscuit", "mille-feuille", "éclair", "brownie"],
|
||||
"price": [2.99, 3.49, 1.99, 4.99, 5.99, 6.99],
|
||||
"weight": [250, 300, 200, 400, 500, 600],
|
||||
}
|
||||
)
|
||||
figure: Figure = Figure(data=[Bar(name="Prix", x=data["product"], y=data["price"])])
|
||||
figure.add_layout_image(
|
||||
layer="above",
|
||||
x=0,
|
||||
y=1.02,
|
||||
xref="paper",
|
||||
yref="paper",
|
||||
sizex=1,
|
||||
sizey=0.075,
|
||||
xanchor="left",
|
||||
yanchor="bottom",
|
||||
source=Image.open("images/python-logo-square.png"),
|
||||
)
|
||||
figure.update_layout(
|
||||
template="seaborn",
|
||||
title="Prix et poids unitaires",
|
||||
font={"family": "Cabin", "size": 13},
|
||||
)
|
||||
figure.show(renderer="browser")
|
||||
Reference in New Issue
Block a user