Data Science Jumpstart with 10 Projects Transcripts
Chapter: Project 10: Making a Snow Report Dashboard with Dash and Plotly
Lecture: Creating a Line Plot in Plotly for Pandas

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In this video, we're going to explore how we can make plots with Plotly instead of Matplotlib. Plotly is running in the browser.
0:08 Matplotlib, what it does is it goes out and generates an image on the server. So, Matplotlib, when you tell it to make a plot,
0:15 will go out and generally make like a PNG image and then bring it back to you. Plotly runs all this and renders all this in the browser.
0:23 So, if you're looking for interactivity, the architecture of Plotly lends itself to better interactivity where you can hover over and things
0:30 don't have quite as much lag as they would with Matplotlib. Let's import Plotly.
0:37 Plotly has this express module that has a simpler interface than just Plotly itself. I'm going to tell Pandas that I want to use Plotly as the backend.
0:47 When I do that, I can plot using Pandas, but instead of getting Matplotlib output, I'm going to get Plotly coming out of that. So, here is a line plot.
0:58 We're sticking the date in the x-axis, and then we're plotting how much snow is on the ground. So, we can see the pattern going on here that
1:07 we have snow on the ground during the winter and then during the summer it melts. Cool thing about Plotly is it is interactive,
1:13 so I can hover over these and zoom into them and see what's going on here.
1:17 You can see that we do have quite a lot of information that is missing from this. It probably needs to be cleaned up a little bit more,
1:23 but we get the basic idea. So, I'm going to do a little pipe here. I'm just going to say I want to query the season that is anything with 2010 to 2011,
1:38 and then let's just do the plot of that. You can see that the season starts somewhere around November and ends around April.
1:46 You can see how much snow is on the ground that it's building up over this time. 2011 was an abnormally high snow year,
1:55 but you would see this fall off really quickly here in the May-June timeframe.


Talk Python's Mastodon Michael Kennedy's Mastodon