Python Data Visualization Transcripts
0:00 Final concept I want to cover here when it comes to displaying multiple charts is how we can layer charts on top of each other.
0:08 So we'll create our bar chart, let's say, we want to add some additional annotations to this.
0:15 So the next thing we can do is develop our rule and this will be a vertical line. We can say let's show the bars plus the rule.
0:27 And now it adds this red bar at the mean fuel cost and marks it is red. So now we've got a nice bar chart showing us where the median or
0:37 the mean fuel cost is. And then the other thing we can do is, let's say we want to get really fancy here and add some text to show what
0:48 those averages are for each period for each year. So now we'll define the text and combine them all together.
0:58 So we'll add the bars, the rule and the text and now we have a nice chart that shows the average for each year,
1:06 the mean fuel cost. And then it also has this red bar for the average across all of the years. And so this ability to combine things together is a
1:17 very powerful function within altair. That gives us a lot of flexibility for creating custom visualizations and you may look at this one and realize,
1:26 I don't like the way that the numbers don't show up within the graph. So the way we could fix that is maybe make it a little bit wider.
1:36 So let's take the bars rule and text and add a properties attribute with the width
1:43 of 700 in this case. And now we have a larger chart and those numbers show up within the chart and look a lot better.
1:52 So this is really interesting and useful as you start to go into your visualizations and
1:58 want to customize them with additional information to drive your business insights.
2:03 This can be a great way to annotate the charts and call out the data that you think is most interesting or relevant to your specific analysis.