Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Exporting to HTML
00:00 In the last lesson, you created two charts that are linked together by interactivity. In this lesson, you’ll see how you can export that to HTML and share the chart with anyone, even someone who doesn’t have Python or Jupyter installed.
00:14
To create a standalone HTML file out of your charts, which can then be viewed in any web browser, you can use the .save() method.
00:22
In the code, create a new variable called export_chart. Make it equal to scatter & bars, which is both charts shown at the same time.
00:32
I’ll scroll down a bit so you can see the code. And on this export_chart variable, call the .save() method and pass in a file name.
00:41
Let’s call it charts.html. When you run this code, it’ll create an HTML file in the same folder as this Jupyter Notebook, which you can view in a web browser.
00:52 When you open your web browser, you’ll see the same chart that was previously in the Jupyter Notebook, and when you start selecting some of the data points in the top chart, you’ll see the same interactivity that you saw in the Jupyter Notebook.
01:06 And that’s it! You’ve seen all the code from starting a small chart all the way to creating two charts which are linked together with interactivity and then exported into an HTML file.
01:18 Before we wrap up the course, in the next lesson, you’ll learn about some of the gotchas and limitations around Altair.
Become a Member to join the conversation.