Creating line charts

In this recipe, we will see how to create a line chart. We have already introduced this kind of chart in Chapter 3, Drawing Your First Plots and Customizing Them, and we have seen how to make the plots with matplotlib. This time we'll focus on how to create and share them with Plot.ly.

Getting ready

Before starting, you need to set up your credentials for the Plot.ly platform in the programming environment:

$ python -c "import plotly; plotly.tools.set_credentials_file(username='DemoAccount', api_key='mykey')"

Replace Demo Account and mykey with your Plotly username and API key.

How to do it...

The following code example demonstrates how to plot two curves. In particular, we will:

  1. Generate the data to plot (a sine and a cosine wave). ...

Get Python Data Visualization Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.