Skip to content

Instantly share code, notes, and snippets.

@benech17
Created November 28, 2022 14:29
Show Gist options
  • Save benech17/3948686a3b024d14a361c6c568e67589 to your computer and use it in GitHub Desktop.
Save benech17/3948686a3b024d14a361c6c568e67589 to your computer and use it in GitHub Desktop.
2e exemple bokeh
from bokeh.plotting import figure, show
# preparation des données à afficher
x = [1, 2, 3, 4, 5]
y1 = [6, 7, 2, 4, 5]
y2 = [2, 3, 4, 5, 6]
y3 = [4, 5, 5, 7, 2]
# creation d'une nouvelle visualisation en précisant, le titre et les axes
p = figure(title="Exemple de couches multiples affichées", x_axis_label="x", y_axis_label="y")
# ajout de plusieurs couches de visualisation
p.vbar(x=x, top=y2, legend_label="Bars", width=0.5, bottom=0, color="red") # Barres horizontales
p.line(x, y1, legend_label="Lignes", color="blue", line_width=2) # Tracé en ligne
p.circle(x, y3, legend_label="cercles", size=12,fill_color="red",
fill_alpha=0.5, line_color="blue") # Tracé en cercle
# Personnalisation de la légende
p.legend.location = "top_left" # emplacement de la légende
p.legend.title = "Ma légende" # titre
p.legend.label_text_font = "arial" # Police d'écriture
p.legend.label_text_font_style = "italic" # Style d'écriture
p.legend.label_text_color = "white" # Couleur d'écriture
p.legend.border_line_width = 2
p.legend.border_line_color = "red" # couleur de bordure
p.legend.border_line_alpha = 0.8 # Transparence de bordure
p.legend.background_fill_color = "red"# Couleur de remplissage
p.legend.background_fill_alpha = 0.2 # Transparence de l'arrière plan
# Affichage des resultats
show(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment