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.
When integrating Plotly graphs into your UI code, note that the method for displaying the graph differs from a regular Python script. Instead of using fig.show()
, use rx.plotly(data=fig)
within your UI code to ensure the graph is properly rendered and displayed within the user interface
Basic 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.
Plot as State Var
If the figure is set as a state var, it can be updated during run time.
Adding Styles and Layouts
Use update_layout()
method to update the layout of your chart. Checkout Plotly Layouts for all layouts props.