File size: 610 Bytes
8e04495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from matplotlib.figure import Figure

import mesop as me


def load(e: me.LoadEvent):
  me.set_theme_mode("system")


@me.page(
  on_load=load,
  security_policy=me.SecurityPolicy(
    allowed_iframe_parents=["https://google.github.io", "https://huggingface.co"]
  ),
  path="/plot",
)
def app():
  with me.box(style=me.Style(margin=me.Margin.all(15))):
    # Create matplotlib figure without using pyplot:
    fig = Figure()
    ax = fig.subplots()  # type: ignore
    ax.plot([1, 2])  # type: ignore

    me.text("Example using matplotlib:", type="headline-5")
    me.plot(fig, style=me.Style(width="100%"))