بنقرة واحدة
plot
Annoter visuellement des plots matplotlib et les modifier via référence par couleur
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Annoter visuellement des plots matplotlib et les modifier via référence par couleur
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | plot |
| description | Annoter visuellement des plots matplotlib et les modifier via référence par couleur |
| metadata | {"short-description":"Annotation visuelle de plots"} |
Workflow pour annoter des plots matplotlib avec des zones colorées et les modifier par référence.
| Commande | Description |
|---|---|
/plot ou /plot show | Affiche le plot actuel et ses annotations |
/plot load <chemin> | Charge une image et lance l'annotateur |
/plot annotate | Lance l'annotateur HTML |
/plot zones | Liste les annotations par groupe |
/plot apply | Applique les modifications au code source |
/plot list | Liste tous les plots sauvegardés |
/plot load /chemin/vers/figure.png
Actions:
~/.claude/plots/current.pngL'utilisateur dans le navigateur:
/plot apply
Claude:
{
"zones": [
{
"id": "blue",
"color": "#2196F3",
"type": "rect",
"group_id": 2,
"bbox": [1730, 115, 2266, 300],
"label": null
},
{
"id": "blue",
"color": "#2196F3",
"type": "text",
"group_id": 2,
"text": "remplacer Dynamic par Updated",
"position": [726, 172],
"label": null
},
{
"id": "red",
"color": "#F44336",
"type": "rect",
"group_id": 3,
"bbox": [197, 1283, 2299, 1487],
"label": null
},
{
"id": "red",
"color": "#F44336",
"type": "text",
"group_id": 3,
"text": "plus petit labels",
"position": [1758, 1490],
"label": null
}
],
"created": "2026-01-22T16:09:51.051Z",
"plot_name": "current"
}
Interprétation:
/plot apply# Pseudo-code
groups = {}
for zone in annotations["zones"]:
gid = zone["group_id"]
if gid not in groups:
groups[gid] = {"shapes": [], "text": None, "color": zone["id"]}
if zone["type"] == "text":
groups[gid]["text"] = zone["text"]
else:
groups[gid]["shapes"].append(zone)
| Zone (bbox) | Texte | Action matplotlib |
|---|---|---|
| Titre (haut centre) | "changer X" | ax.set_title(...) |
| Légende | "modifier label" | ax.legend(...) ou dans plot()/scatter() |
| Axes X (bas) | "plus petit" | ax.tick_params(axis='x', labelsize=...) |
| Axes Y (gauche) | "rotation" | ax.set_ylabel(..., rotation=...) |
| Points scatter | "enlever bordure" | scatter(..., edgecolors='none') |
| Ligne | "changer couleur" | plot(..., color='...') |
Pour une image 4200×1650:
loc=current_meta.json pour obtenir source_scriptlabelsize=8)cd {regen_cwd} && {regen_cmd}
/plot show# 1. Afficher l'image
Read("~/.claude/plots/current.png")
# 2. Lire métadonnées
meta = Read("~/.claude/plots/current_meta.json")
# 3. Lire annotations
annotations = Read("~/.claude/plots/current_annotations.json")
# 4. Résumer par groupe
for group_id, items in group_by(annotations, "group_id"):
shapes = [i for i in items if i["type"] != "text"]
text = next((i["text"] for i in items if i["type"] == "text"), None)
print(f"Groupe {group_id}: {len(shapes)} forme(s), instruction: {text}")
/plot annotateLance l'annotateur vide (sans image). L'utilisateur peut drag & drop ou cliquer "current.png".
fuser -k 8888/tcp 2>/dev/null || true
sleep 1
python3 ~/.claude/tools/annotate_server.py &
sleep 2
xdg-open "http://localhost:8888/annotate.html" # Sans ?load=true → démarre vide
/plot zonesLire et afficher current_annotations.json groupé par group_id.
/plot load <chemin>cp <chemin> ~/.claude/plots/current.png# Extraire nom fichier
filename=$(basename <chemin> .png)
# Trouver projet root
project_root=$(git -C $(dirname <chemin>) rev-parse --show-toplevel 2>/dev/null)
# Chercher dans les .py
grep -r "$filename" --include="*.py" "$project_root"
?load=true pour charger l'image automatiquement:
fuser -k 8888/tcp 2>/dev/null || true
sleep 1
python3 ~/.claude/tools/annotate_server.py &
sleep 2
xdg-open "http://localhost:8888/annotate.html?load=true"
/plot applyIMPORTANT: Suivre cette logique exacte avec CONFIRMATION OBLIGATOIRE:
Lire les fichiers
annotations = ~/.claude/plots/current_annotations.json
meta = ~/.claude/plots/current_meta.json
Grouper les annotations
Pour chaque group_id unique:
- Collecter les formes (rect, circle, line)
- Extraire le texte (instruction)
Pour chaque groupe, analyser:
Lire le code source (meta.source_script)
AFFICHER UN RÉSUMÉ DÉTAILLÉ (NE PAS MODIFIER ENCORE!)
## Modifications proposées
**Fichier:** `/chemin/vers/script.py`
### Groupe X (couleur):
- **Zone ciblée:** [description de l'élément, ex: "Titre principal", "Légende", "Labels axe X"]
- **Instruction:** "texte de l'annotation"
- **Modification proposée:**
- Ligne ~XX: `ancien_code`
- Devient: `nouveau_code`
### Groupe Y (couleur):
- **Zone ciblée:** ...
- **Instruction:** ...
- **Modification proposée:** ...
---
**Confirmer ces modifications?** (oui/non)
ATTENDRE LA CONFIRMATION EXPLICITE
Appliquer les modifications (seulement après confirmation)
Régénérer si regen_cmd disponible
| Action | Contrôle |
|---|---|
| Zoom | Molette souris |
| Pan | Espace+drag, Clic-droit+drag, ou bouton ✋ |
| Dessiner | Choisir outil (rect/circle/line/freedraw/text) |
| Texte | Outil 📝 + clic → modal stylée (Enter=OK, Esc=annuler) |
| Nouveau groupe | Bouton ➕ (sépare les annotations) |
| Labels | Bouton 🏷️ → panneau latéral |
| Sauvegarder | Bouton 💾 (auto-save sur disque) |
| Supprimer | Sélection + Delete |
| Fichier | Contenu |
|---|---|
~/.claude/plots/current.png | Plot actuel (sauvegardé auto quand user drop + save) |
~/.claude/plots/current_annotated.png | Plot avec annotations visuelles |
~/.claude/plots/current_meta.json | Métadonnées (source_script détecté auto) |
~/.claude/plots/current_annotations.json | Zones annotées avec group_id |
~/.claude/tools/annotate.html | App HTML (Fabric.js) |
~/.claude/tools/annotate_server.py | Serveur Python (port 8888) |
Quand l'utilisateur drop une image dans l'annotateur et clique Save:
current.pnggrep -r "filename" --include="*.py")current_meta.json est mis à jour avec source_scriptProjets scannés:
/plot load~/Github, /media/*/Data/Github| Couleur | Hex | Usage suggéré |
|---|---|---|
| blue | #2196F3 | Annotations principales |
| red | #F44336 | Erreurs, suppressions |
| green | #4CAF50 | Validations, OK |
| yellow | #FFEB3B | Attention, warnings |
| orange | #FF9800 | Modifications secondaires |
| purple | #9C27B0 | Notes spéciales |
Utilisateur: /plot load /media/data/outputs/fig_trends.png
Claude: Plot chargé.
- Source: /media/data/scripts/plot_trends.py
- Commande regen: python scripts/plot_trends.py --output outputs/
- Annotateur: http://localhost:8888/annotate.html
[Utilisateur annote: rect bleu sur légende + texte "Dynamic → Updated"]
[Utilisateur annote: rect rouge sur x-axis + texte "smaller font"]
[Utilisateur clique 💾]
Utilisateur: /plot apply
Claude: J'ai analysé 2 groupes d'annotations. Voici les modifications proposées:
---
## Modifications proposées
**Fichier:** `/media/data/scripts/plot_trends.py`
### Groupe 2 (bleu) - Légende
- **Zone ciblée:** Légende (bbox: 2491,1146 → 3054,1301)
- **Instruction:** "Dynamic → Updated"
- **Modification proposée:**
- Ligne 45: `label='Dynamic (Sentinel-2)'`
- Devient: `label='Updated (Sentinel-2)'`
### Groupe 3 (rouge) - Labels axe X
- **Zone ciblée:** Labels axe X (bbox: 197,1283 → 2299,1487)
- **Instruction:** "smaller font"
- **Modification proposée:**
- Ajouter après ligne 52: `ax.tick_params(axis='x', labelsize=8)`
---
**Confirmer ces modifications?** (oui/non)
Utilisateur: oui
Claude: Modifications appliquées ✓
- Ligne 45: label mis à jour
- Ligne 53: tick_params ajouté
Régénération du plot...
[Commande exécutée]
✅ Nouveau plot généré. Voici le résultat:
[Affiche le nouveau plot]