Rym Guerbi Michaut
Rym Guerbi Michaut

Reputation: 193

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!

Upvotes: 1

Views: 95

Answers (2)

Lucio Carrara
Lucio Carrara

Reputation: 23

If you need a lot of control you can use plotly directly in your Taipy application.

import plotly.graph_objects as go
from plotly.subplots import make_subplots

...

state.fig = go.Figure()

# Make 4 subplots in a 2x2 arrangement
state.fig = make_subplots(rows=2, cols=2, x_title="X axix", y_title="Y axis")

# Add one trace in the top left subplot
state.fig.add_trace(go.Scatter(x=xdata,
                               y=ydata,
                               mode='lines',
                               name='name',
                               row=1,
                               col=1)

Upvotes: 0

Florian Jacta
Florian Jacta

Reputation: 1521

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

Upvotes: 1

Related Questions