2025.44 changes

This commit is contained in:
2025-10-27 21:20:17 +01:00
parent e4579e4887
commit c45c6e9f2d
25 changed files with 446 additions and 26 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1009 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 58 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 922 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,17 @@
import pandas as pd
from plotly import express as px
from plotly.colors import sequential, qualitative
df = pd.DataFrame(data={
"month": [f"2005-{i:02d}" for i in range(1, 13)],
"temperature": [4.4, 6.8, 9.2, 11.5, 13.8, 16.3, 19.1, 21.4, 22.9, 20.5, 17.2, 13.9]
})
plot = px.bar(
df, x="month", y="temperature", color="temperature", template="seaborn",
title="Temperatures mensuelles de 2005",
color_continuous_scale=sequential.Turbo,
labels={"month": "Mois", "temperature": "Température (°C)"}
)
plot.layout.update({"font": {"family": "Cabin", "size": 13}})
plot.show()

View File

@@ -0,0 +1,17 @@
import pandas as pd
from plotly import express as px
from plotly.colors import sequential, qualitative
df = pd.DataFrame(data={
"month": [f"2005-{i:02d}" for i in range(1, 13)],
"temperature": [4.4, 6.8, 9.2, 11.5, 13.8, 16.3, 19.1, 21.4, 22.9, 20.5, 17.2, 13.9]
})
plot = px.bar(
df, x="month", y="temperature", color="temperature", template="seaborn",
title="Temperatures mensuelles de 2005",
color_continuous_scale=["#FF0020", "rgb(255,165,0)", "rgba(255,255,0,0.8)"],
labels={"month": "Mois", "temperature": "Température (°C)"}
)
plot.layout.update({"font": {"family": "Cabin", "size": 13}})
plot.show()

View File

@@ -0,0 +1,14 @@
import pandas as pd
from plotly import express as px
from plotly.colors import qualitative
data = pd.DataFrame(data={
"name": ["headphones", "microphone", "speaker", "powerbank", "tablet", "laptop"],
"price": [99.99, 49.99, 149.99, 29.99, 199.99, 279.99],
"merchant": ["amazon", "amazon", "bestbuy", "amazon", "newegg", "amazon"],
"color": ["black", "silver", "white", "red", "gray", "silver"]
})
figure = px.pie(data, values="price", names="name", title="Prix", color_discrete_sequence=qualitative.Bold)
figure.layout.update({"template": "seaborn", "title": "Prix à l'unité", "font": {"family": "Cabin", "size": 13}, "width": 1080, "height": 720})
figure.update_traces(textposition="inside", textinfo="percent+label", texttemplate="%{label}<br>%{value}€ (%{percent:.2%})")
figure.show()

View File

@@ -0,0 +1,19 @@
import pandas as pd
from plotly._subplots import SubplotXY
from plotly.subplots import make_subplots
from plotly.graph_objs import Figure, Bar
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 = make_subplots(rows=1, cols=3, subplot_titles=("Prix", "Poids unitaires"))
subplot = figure.get_subplot(row=1, col=2)
subplot.xaxis["domain"] = [0.3555555, 1.0]
print(subplot, dir(subplot))
figure.add_trace(Bar(name="Prix", x=data["product"], y=data["price"]), row=1, col=1)
figure.add_trace(Bar(name="Poids", x=data["product"], y=data["weight"]), row=1, col=2)
figure.update_layout(template="seaborn", title="Prix et poids unitaires", font={"family": "Cabin", "size": 13})
figure.update_traces(row=1, col=2, specs=2)
figure.show(renderer="browser")

View File

@@ -0,0 +1,14 @@
import pandas as pd
from plotly.subplots import make_subplots
from plotly.graph_objs import Figure, Bar
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 = make_subplots(rows=1, cols=2, column_widths=[0.6, 0.4], row_heights=[1.0])
figure.add_trace(Bar(name="Prix", x=data["product"], y=data["price"]), row=1, col=1)
figure.add_trace(Bar(name="Poids", x=data["product"], y=data["weight"]), row=1, col=2)
figure.update_layout(template="seaborn", title="Prix et poids unitaires", font={"family": "Cabin", "size": 13})
figure.show()

View File

@@ -0,0 +1,55 @@
import plotly.express as px
from plotly.graph_objects import Figure, Scatter
COLS: int = 3
fig: Figure = px.colors.sequential.swatches_continuous()
fig3: Figure = px.colors.qualitative.swatches()
figb: Figure = px.colors.sequential.swatches()
fig2 = Figure(layout={
"title": "Palette de couleurs continues Plotly Sequential",
"font": {"family": "Cabin", "size": 13},
"xaxis": {"visible": False, "showticklabels": False},
"yaxis": {"visible": False, "showticklabels": False},
"legend": {"visible": False},
"width": 1400,
}).set_subplots(rows=22, cols=COLS)
for i, p in enumerate(fig.select_traces()): #type: int, Scatter
fig2.add_trace(p, row= (i // COLS) + 1, col=(i % COLS) + 1)
fig2.update_xaxes({"visible": False, "showticklabels": False, "showgrid": False})
fig2.update_yaxes({"visible": True, "showticklabels": True, "showgrid": False})
fig2.update_yaxes(tickfont={"size": 11}, ticksuffix=" ")
fig2.write_image("eda-plotly-colors-continuous.svg")
# fig2.show(renderer="browser")
fig4 = Figure(layout={
"title": "Palette de couleurs séquentielles Plotly Sequential",
"font": {"family": "Cabin", "size": 13},
"xaxis": {"visible": False, "showticklabels": False},
"yaxis": {"visible": False, "showticklabels": False},
"legend": {"visible": False},
"width": 1400,
"margin": {"t": 100, "b": 50, "l": 60, "r": 50},
}).set_subplots(rows=22, cols=COLS)
for i, p in enumerate(figb.select_traces()): #type: int, Scatter
fig4.add_trace(p, row= (i // COLS) + 1, col=(i % COLS) + 1)
fig4.update_xaxes({"visible": False, "showticklabels": False, "showgrid": False})
fig4.update_yaxes({"visible": True, "showticklabels": True, "showgrid": False})
fig4.update_yaxes(tickfont={"size": 11}, ticksuffix=" ")
fig4.write_image("eda-plotly-colors-sequential.svg")
fig3.update_layout({
"title": "Palette de couleurs qualitatives Plotly Qualitative",
"font": {"family": "Cabin", "size": 13},
"xaxis": {"visible": False, "showticklabels": False},
"yaxis": {"visible": False, "showticklabels": False},
"legend": {"visible": False},
"width": 1200,
"margin": {"t": 100, "b": 50, "l": 60, "r": 50},
})
fig3.update_xaxes({"visible": False, "showticklabels": False, "showgrid": False})
fig3.update_yaxes({"visible": True, "showticklabels": True, "showgrid": False})
fig3.update_yaxes(tickfont={"size": 11}, ticksuffix=" ")
fig3.write_image("eda-plotly-colors-qualitative.svg")

View 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")

View File

@@ -0,0 +1,20 @@
import pandas as pd
from plotly.graph_objs import Figure, Bar, Scatter
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_hrect(y0=2.75, y1=4.5, fillcolor="gray", opacity=0.25, layer="below")
figure.update_layout(
template="seaborn",
title="Prix et poids unitaires",
font={"family": "Cabin", "size": 13},
xaxis={"title": "Produit", "showgrid": False},
yaxis={"title": "Prix (€)", "showgrid": False}
)
figure.show(renderer="browser")