Legacy – Multiple Sub Charts Workout
- 03:37
Workout demonstrating how to create a chart with multiple subcharts in Python.
Glossary
Matplotlib Sub ChartsTranscript
Let us now look at an example of plotting categorical values. So let's assume we have a list of tickers and the closing share prices. And we would like to plot the figure, and you would like to plot three different sub charts in the same window. How do you do it. So before we do anything, we need to first import the matplotlib library. Now read create the data. So we have the names or the tickers as Amazon, Apple, and Google.
Now we have the closing share price one is 1734.7, 262.1, 1301.4. Lets run this. So that's the data set. Now, we would like to plot the figure. And first we would define the figure size, there are many options of finger sizes. But when you want to plot three fingers, one option is setting the figure size as nine and three. Now you want to make the first subplot. So you need to define where you want the first subplot to be. So the first subplot will be at the first plot three, and one what the one at the end meaning it's in the first position out of the three plots. And this would be a bar chart, bar of names and values. The next one would be one three too, in the second position, and this would be a scatterplot of the names and values. Again, the third sub plot, now you can guess it, it's going to be the third place. Out of the three sub plot, the first number represents the number of rows, we have one row out of the three columns, it's in the third position. So that's how the 133 comes out, and one three through in the first group, out of the three columns, it's in the second position. And that's the same case with 131. And now this would be a histogram, or it's just a standard plot. Names and values. Now we need the subtitling of the plot. So we said plot subtitle. Price companies standard procedure plt . show, and we run this. Perfect, there we go. We've called three different plots. The first one would be a bar chart, the second would be a scatter plot. And the third would be a standard plot, which is a line perfect. And it's a similar procedure to do any different kind of plot, which are three different sub plots or it can be four or five, any number