File size: 2,722 Bytes
5846c4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import plotly.graph_objects as go
import numpy as np
import pandas as pd

# Paramètres de l'ellipse (galaxie) et échantillonnage
num_points = 512
cx, cy = 1.5, 0.5           # centre (au milieu des ranges actuels)
a, b = 1.3, 0.45            # demi‑axes (ellipse horizontale)

# Échantillonnage en coordonnées polaires puis transformation elliptique
# r concentré vers le centre (alpha>1) pour densité centrale façon galaxie
theta = 2*np.pi*np.random.rand(num_points)
r_base = np.random.rand(num_points)**2

# Légère irrégularité pour un aspect plus naturel
noise_x = 0.015*np.random.randn(num_points)
noise_y = 0.015*np.random.randn(num_points)

x = cx + a * r_base * np.cos(theta) + noise_x
y = cy + b * r_base * np.sin(theta) + noise_y

# Taille plus grande au centre, plus petite en périphérie
# On conserve la même échelle finale qu'avant: (valeur in [0,1]) -> (val+1)*5
z_raw = 1 - r_base                 # 1 au centre, 0 au bord
sizes = (z_raw + 1) * 5            # 5..10, comme précédemment

df = pd.DataFrame({
    "x": x,
    "y": y,
    "z": sizes,                   # réutilisé pour size+color comme avant
})

def get_label(z):
    if z<0.25:
        return "smol dot"
    if z<0.5:
        return "ok-ish dot"
    if z<0.75:
        return "a dot"
    else:
        return "biiig dot"

# Les labels sont fondés sur l'intensité centrale (z_raw en [0,1])
df["label"] = pd.Series(z_raw).apply(get_label)

fig = go.Figure()

fig.add_trace(go.Scatter(
    x=df['x'],
    y=df['y'],
    mode='markers',
    marker=dict(
        size=df['z'],
        color=df['z'],
        colorscale=[
            [0, 'rgb(78, 165, 183)'],      # Light blue
            [0.5, 'rgb(206, 192, 250)'],    # Purple
            [1, 'rgb(232, 137, 171)']       # Pink
        ],
        opacity=0.9,
    ),
        customdata=df[["label"]],
    hovertemplate="Dot category: %{customdata[0]}",
    hoverlabel=dict(namelength=0),
    showlegend=False
))


fig.update_layout(
    autosize=True,
    paper_bgcolor='rgba(0,0,0,0)',
    plot_bgcolor='rgba(0,0,0,0)',
    showlegend=False,
    margin=dict(l=0, r=0, t=0, b=0),
    xaxis=dict(
        showgrid=False,
        zeroline=False,
        showticklabels=False,
        range=[0, 3]
    ),
    yaxis=dict(
        showgrid=False,
        zeroline=False,
        showticklabels=False,
        scaleanchor="x",
        scaleratio=1,
        range=[0, 1]
    )
)

fig.show()

fig.write_html("../../src/fragments/banner.html", 
               include_plotlyjs=False, 
               full_html=False, 
               config={
                   'displayModeBar': False,
                   'responsive': True, 
                   'scrollZoom': False,
               })