How to display Plotly visualizations in Amazon Sagemaker Studio Lab

Austin Lasseter
3 min readJun 9, 2022

--

Amazon SageMaker Studio Lab is a free machine learning (ML) development environment that provides the compute, storage (up to 15GB), and security — all at no cost — for anyone to learn and experiment with ML! It’s a real game changer for ML students and enthusiasts.

If you haven’t already done so, check out my other blog posts about getting started with SMSL and pulling your first repo from Github.

Introducing Plotly for Visualizations

In this post, we’ll learn about how to display Plotly visualizations inside the jupyterlab notebooks which you’ll be running on SMSL. Plotly is an industry-leading tool for creating and displaying data with web-based charts and graphs. It’s a great addition to your SMSL environment, but it does take a little setting up to make it work.

To kick things off, you can write your own plotly code or you can clone this repo that has an example notebook called create-html-plots.ipynb. You can clone the repo using the icon in the left navbar, like this:

Inside SMSL, the first thing you’ll need to do is enable extensions, by clicking on the puzzle icon in the left navbar:

FWIW, you can also achieve this by clicking on the same option in Settings, like this:

Then click on search icon at the top of the left navbar, and search for “jupyter-chart-editor”.

When you try to do this, you’ll get the following error message — there are some dependencies we need to install first!

Open up a new terminal session using the Launcher tool. In the repo you cloned, run the shell script ./aws_studio_setup.sh which includes installation code for the jupyterlab extensions and dependencies.

Once this script is finished running, you should be able to successfully click “install” for the extension jupyterlab-chart-editor. This time, instead of the error message, you should see a banner indicating that a new build is needed. Click “Rebuild” like this.

Click yes, and then go get a cup of coffee. It’s going to take a minute. When you come back, your new environment should be ready to go.

Try running some of the code in create-html-plots.ipynb. The charts should now render successfully. If everything ran according to plan, you should see something like the following:

Be sure to check out my next two blog posts in this series:

Final note: Additional information can be found from the following sources:

--

--