Search code examples
taipy

Creating subplots with Taipy


I’m trying to find some documentation about subplots in Taipy.

Is it possible to do this with Taipy?

Thanks in advance!


Solution

  • It is possible to have subplots. For example, for polar charts, an example can be found in the Taipy documentation here.

    However, we recommend using the layout block to create subplots. See below for a simple example:

    from taipy.gui import Gui
    
    # Sample small plot definition
    data = {
        "x": [1, 2, 3, 4, 5],
        "y": [5, 40, 80, 120, 160],
    }
    
    # Sample small plot definition
    data2 = {
        "x": [1, 2, 3, 4, 5],
        "y": [1, 4, 3, 10, 20],
    }
    
    md = """
    <|layout|columns=1 1|
    <|{data}|chart|>
    
    <|{data2}|chart|>
    
    <|{data}|chart|type=bar|>
    
    <|{data2}|chart|type=bar|>
    |>
    """
    
    Gui(md).run()
    

    enter image description here