Layout widgets allow you to control the arrangement of other widgets in your notebook interface.
Layout widgets provide flexible ways to arrange other widgets in your notebook interface. They help you create complex, responsive layouts by combining multiple widgets together.
Below is a comprehensive list of supported layout widget types.
Row Layout
The Row layout widget arranges widgets horizontally in a single row.
Copy
Ask AI
from lplots.widgets.row import w_rowfrom lplots.widgets.select import w_selectimport plotly.express as px# Get the iris datasetdf = px.data.iris()# Get numeric columns for axis selectionnumeric_cols = df.select_dtypes(include=['float64', 'int64']).columns.tolist()# Create a column of select widgets with defaults set to first two columnsx_axis = w_select( label="X-axis", options=numeric_cols, default=numeric_cols[0])y_axis = w_select( label="Y-axis", options=numeric_cols, default=numeric_cols[1])w_row(items=[x_axis, y_axis])
key: string optional unique identifier for the widget
items: list[BaseWidget] list of widgets to arrange horizontally
Column Layout
The Column layout widget arranges widgets vertically in a single column.
Copy
Ask AI
from lplots.widgets.column import w_columnfrom lplots.widgets.select import w_selectimport plotly.express as px# Get the iris datasetdf = px.data.iris()# Get numeric columns for axis selectionnumeric_cols = df.select_dtypes(include=['float64', 'int64']).columns.tolist()# Create a column of select widgets with defaults set to first two columnsx_axis = w_select( label="X-axis", options=numeric_cols, default=numeric_cols[0])y_axis = w_select( label="Y-axis", options=numeric_cols, default=numeric_cols[1])w_column(items=[x_axis, y_axis])
Layout widgets can be nested to create complex arrangements. For example, you can place a row of widgets inside a grid cell, or create a column of rows.
Copy
Ask AI
from lplots.widgets.grid import w_gridfrom lplots.widgets.column import w_columnfrom lplots.widgets.select import w_selectfrom lplots.widgets.plot import w_plotimport plotly.express as px# Get the iris datasetdf = px.data.iris()# Get numeric columns for axis selectionnumeric_cols = df.select_dtypes(include=['float64', 'int64']).columns.tolist()# Create a column of select widgets with defaults set to first two columnsx_axis = w_select( label="X-axis", options=numeric_cols, default=numeric_cols[0])y_axis = w_select( label="Y-axis", options=numeric_cols, default=numeric_cols[1])plot_color = w_select( label="Color", options=["blue", "red", "green"], default="blue")# Create column layout for widgetscolumn = w_column(items=[x_axis, y_axis, plot_color])# Create scatter plotfig1 = px.scatter( df, x=x_axis.value, y=y_axis.value, template="simple_white")# Update marker colorfig1.update_traces(marker=dict(color=plot_color.value))# Render the plotplot1 = w_plot(source=fig1)# Add the column and plot to the gridwith w_grid(columns=12) as grid: grid.add(item=column, col_span=3) grid.add(item=plot1, col_span=9)
Layout widgets are reactive to changes in their child widgets. When a child widget is updated, the layout will automatically adjust to accommodate the changes while maintaining the specified arrangement.