Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Slope — Before / After Comparison Chart

Signature

sp.slope(title, labels, left, right, *, variant="basic", left_label="Before", right_label="After", palette=None, show_text=True, **kwargs) -> Chart

Description

sp.slope() renders the entire slope-chart family: two parallel value axes (left / right) with one connector per row. The variant keyword swaps the connector style without changing any other parameter. Slope charts excel at before/after comparisons, A/B test outcomes, ranking shifts, KPI changes between periods, and any pair-wise change across many entities.

Parameters

ParameterUsed by variants
left_labeldiverging
palettebumps, monochrome
right_labeldiverging
show_textbasic, bumps, curved, highlighted, monochrome, stepped, thick
widthdiverging

Returns

Chart — object with .html property and .show() method.


Tips

  • Use sort_order="asc" / "desc" to reorder rows by left value before drawing.
  • The "diverging" and "thick" variants encode magnitude visually — perfect for executive summaries.
  • For rank shifts (positions in a league), prefer "bumps" rather than "basic".
  • Combine palette= with "monochrome" to match brand colours per category.

Signature

sp.slope(title, labels, left, right, *, variant="basic", left_label="Before", right_label="After", palette=None, show_text=True, **kwargs) -> Chart

Description

sp.slope() produit toute la famille des slope charts : deux axes de valeurs parallèles (gauche / droite) avec un connecteur par ligne. Le mot-clé variant permute le style du connecteur sans changer aucun autre paramètre. Idéal pour comparer avant/après, résultats A/B, changements de classement, KPI entre périodes, et toute évolution par paire sur de nombreuses entités.

Paramètres

ParamètreUtilisé par variantes
left_labeldiverging
palettebumps, monochrome
right_labeldiverging
show_textbasic, bumps, curved, highlighted, monochrome, stepped, thick
widthdiverging

Retour

Chart — objet avec propriété .html et méthode .show().


Astuces

  • Utilisez sort_order="asc" / "desc" pour réordonner les lignes selon left avant le rendu.
  • Les variantes "diverging" et "thick" encodent visuellement la magnitude — parfaites pour un résumé exécutif.
  • Pour les changements de rang (positions dans un classement), préférez "bumps" à "basic".
  • Combinez palette= avec "monochrome" pour aligner les couleurs sur les catégories de marque.