Plotly
Plotly is a graphing library that can be used to create interactive graphs. Use the rx.plotly component to wrap Plotly as a component for use in your web page. Checkout Plotly for more information.
fig.show(), use rx.plotly(data=fig) within your UI code to ensure the graph is properly rendered and displayed within the user interfaceBasic Example
Let's create a line graph of life expectancy in Canada.
3D graphing example
Let's create a 3D surface plot of Mount Bruno. This is a slightly more complicated example, but it wraps in Reflex using the same method. In fact, you can wrap any figure using the same approach.
ExpandCollapse
📊 Dataset source: mt_bruno_elevation.csv
Plot as State Var
If the figure is set as a state var, it can be updated during run time.
ExpandCollapse
Adding Styles and Layouts
Use update_layout() method to update the layout of your chart. Checkout Plotly Layouts for all layouts props.
ExpandCollapse
API Reference
rx.plotly
Display a plotly graph.
Props
| Prop | Type | Description |
|---|---|---|
data | Figure | The figure to display. This can be a plotly figure or a plotly data json. |
layout | dict | The layout of the graph. |
template | Template | The template for visual appearance of the graph. |
config | dict | The config of the graph. |
use_resize_handler | bool | If true, the graph will resize when the window is resized. |