Python Data Visualization Transcripts
Chapter: Plotly
Lecture: Additional plot types

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we've gone through how to use some colors and other customizations. Let's go through some other plot types.
0:07 This example I want to create a box plot. So I use the box function and pass in the X. And Y. For this individual plots.
0:17 So we want to look at the fuel cost as well as the class summary. And then I also add color.
0:24 I update the labels and then I also decide that I don't want to show the legend. So let me show you what that looks like.
0:32 So right now I have the legend but it's really duplicating the information I have here So I want to turn it off and so I use this fig update layout
0:42 and show legend equals false to make sure that that doesn't show. So now I have my box plots and this is a really nice way to see
0:50 what the distribution the fuel cost looks like across these different summaries.
0:53 And then the hover effect that we have seen with plotly works well here. So you can see the medium,
1:01 the mean, the portals, the upper fence as well as some of these outliers So this is where you get some really powerful features a plotly to help
1:10 you understand the data and quickly kind of see what's going on with some of the
1:14 outliers in this specific case, if we wanted to do a strip plot we would do the exact same thing instead of a box we would say P.
1:23 X.strip. I'm gonna turn off my legend as well. And now we have a strip plot. So you can see each individual observation. There's a lot of detail here.
1:36 But a good way to see all the observations for these specific vehicles. And then I'm going to show how we can do some annotations on our plots.
1:46 So let me plot this and I'll show you what I'm doing. So I want to show my fuel distribution but also add a line with the average
1:54 and annotate that average. So what we've done here is created that average cost. I'm rounding it to make it a little bit easier to read.
2:03 I create my histogram. I've added a different qualitative color sequence in this case G10. Now I'm using update Y axis to say a different title.
2:15 So instead of count, it says number of cars. And then I'm also updating my figure by adding a vertical line at the average cost
2:25 and I add an annotation and I can use my python f string formatting to put
2:31 that average cost in there with a dollar sign and then finally call figure show to
2:36 view the actual image. So I've had a really nice visualization that I've annotated with my specific data that I wanted to show.
2:44 Similar to what we've done in some of our other plots sticking with the theme of
2:48 histograms. I'm also gonna show how there are different ways that you can configure what you show on your margins with your histogram.
2:57 So this is a little bit different plot that maybe we haven't seen before where we can show the fuel cost is a histogram.
3:03 But up here we can actually see each individual distribution what that box plot looks like
3:09 So it's a powerful way to summarize a lot of data in one plot and we accomplish that by saying the marginal equals box.
3:19 So that tells it to add a box plot on that margin up here, the top margin. This is just a really nice way to get to understand your
3:27 data, get to understand how you can use plotly to quickly configure your visualization and zoom in on the visualization.
3:36 That's going to be right for whatever you're trying to accomplish with that specific task.


Talk Python's Mastodon Michael Kennedy's Mastodon