Python and Plotly

In this example we will show you how to integrate our Python code for generating Plotly figures into the Python Code block and use the Plotly Chart block to display it.

It is important to keep in mind that the runtime is not CPython but rather Pyodide that behaves slightly different. For this use case please pay attention at the following points (see the code below):

  • for installing the Plotly package please use micropip (see the first 2 lines of code below
  • for this example pandas is used behind and it has to be loaded explicitly (please see line 5)
  • for converting the Plotly figure to a JSON use write_json (see line 11)

Now the JSON file is the output of our Python Code, and used further for the JSON description of the Plotly Chart block.

is loading …
is loading …

First Published

in

Last Updated

Comments

Leave a Reply