Skip to content

Commit

Permalink
Add styling/mathtext/latex_outline_shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpap committed May 12, 2024
1 parent 1ea9937 commit 6551749
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions examples/styling/mathtext/latex_outline_shapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from typing import Literal

from bokeh.io import show
from bokeh.plotting import figure

p = figure(
x_range=(5, 85), y_range=(0, 50),
width=1000, height=400,
x_axis_type=None, y_axis_type=None,
toolbar_location=None,
)

x = [10, 20, 30, 40, 50, 60, 70, 80]
padding = 5

p.text(
anchor="center",
x=x,
y=5,
text=["circle", "square", "ellipse", "box\nrectangle", "trapezium", "parallelogram", "diamond", "triangle"],
outline_shape=["circle", "square", "ellipse", "box", "trapezium", "parallelogram", "diamond", "triangle"],
background_fill_color="white", background_fill_alpha=0.8,
padding=padding,
border_line_color="black",
text_font_size="1.2em",
)

def tex(display: Literal["inline", "block"], y: float, color: str):
p.tex(
anchor="center",
x=x,
y=y,
text=[
r"x^{y^z}",
r"\frac{1}{x^2\cdot y}",
r"\int_{-\infty}^{\infty} \frac{1}{x} dx",
r"F = G \left( \frac{m_1 m_2}{r^2} \right)",
r"\delta",
r"\sqrt[3]{\gamma}",
r"x^2",
r"y_{\rho \theta}",
],
outline_shape=["circle", "square", "ellipse", "box", "trapezium", "parallelogram", "diamond", "triangle"],
background_fill_color=color,
background_fill_alpha=0.8,
padding=padding,
border_line_color="black",
display=display,
)

tex("inline", 20, "yellow")
tex("block", 40, "pink")

show(p)

0 comments on commit 6551749

Please sign in to comment.