Python Data Visualization Transcripts
Chapter: Plotly
Lecture: Basic plotting

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we've gone through the basics will create some plots. Here's my new notebook for visualizing data plotly. I've loaded in our data frame and
0:10 the first plot will do is histogram like we have in previous examples. The command to create the histogram is called Histogram.
0:18 We pass into the data frame and the column we want to show the distribution of data and then called to show it.
0:26 And we have a nice histogram here. Similar to what we've seen in previous visualizations.
0:32 Now, one of the things that you'll notice out of the box is that I have an interactive visualization as soon as I call that I can use
0:41 it for a histogram to show the count and the bin for each of these bars. I also have other tools out here to download it to zoom in to
0:50 pan and reset the axes. So play around with this. So you get a feel for what you can do.
0:57 This is really powerful when you start looking at scatter plots and some of the other plots where you want to evaluate individual observations.
1:04 So now if I want to save this plot we use that figure object and write image and it creates an
1:13 SVG So I could create multiple different types and then I'll show you what it looks like. Just load that file directly and now I have a static
1:25 SVG image. It doesn't have any of the interactivity that we saw in the notebook
1:29 but this is really great for embedding in your presentations and emails. We talked a little bit about the plotly
1:37 the graph object. So I wanted to show how to recreate that same histogram using a graph object. So here we create our figure,
1:45 we passed the data as a histogram with the fuel cost eight column as the column that we want to generate the distribution for and we create a histogram
1:57 similar to what we did before. So once again I just call this out so that you're familiar with it and as you progress in your plotly Analysis,
2:04 you may decide you need to do this but I think you can do a lot with plotly express and I would encourage you to continue to stick with that approach.
2:13 So now we'll do a more complex histogram. So we'll create a histogram but we'll add color based on the class summary
2:19 I'm also going to update the labels so that instead of saying fuel cost 08 it says annual fuel cost and then I want to control the bins because we have
2:28 a lot of bins here. I want to maybe use 40 bins. So now I have a more compact visualization, I also have the different colors,
2:38 so you can see the different the different bars by class summary and one of the
2:44 things that's nice with plotly is that I can click on this legend and it actually removes those items. So let's say, I just want to look at cars,
2:52 I could do that or cars and SUVs or other. So this gives you that interactivity. That is really nice out of the box.

Talk Python's Mastodon Michael Kennedy's Mastodon