Why would you want to use a subplot in Python, instead of just making a new graph? There are a few reasons, most having to do with highlighting the similarities between two graphs. But first, strongest reason is that the graphs share a axis, often the X axis. For example, you may want to grab two completely different things across the same time period. Some people would do those on the same graph and have 2Y axis one on the left and one on the right side. This isn’t necessarily a bad idea, but it can get confusing. If you have the space why not give each unit of measure it’s own graph? For example, see the same two pieces of data plotted below:
It’s important that you make clear on the graph that does not have the axes labeled, that the information can be found on the other graph. The subtleties of how you size and space your labels can really matter here, and it’s a situation where it’s particularly important to reach out to someone else and make sure that it is legible to fresh eyes. Because you know how it is supposed to be interpreted, it’s almost impossible to look at it anew and see how a uninformed viewer would interpret it.
Multiple plots with similar goals
Another situation where subplots make sense is when you are using several different Python plots to make the exact same point. Often, the plots will have a few different colors, that are shared between the subplots. For example, take a look at this fictional data about the progression of several groups of students through their school. As you can see, on the first graph, the test scores of the high, low, and middle income students overtime. You can also see a bar graph, using the same color codes, trying to squeeze everyone together on to the same graph would be overwhelming, but by breaking things out but keeping the graphs together you can have several simple but cohesive story is presented into one overall narrative.
Things to be careful of with subplots
It danger of Python subplots is that you will create the accidental impression of similarity where there is none. For example, if the axes are in different units (such as a different time scale) it’s critical that you make that clear because people will assume without checking. Here is an example of what you would not want to do
The process of actually making a subplot in that pot live is very easy. Simply the declare the number of subplots that you want, and the arrangement that you want them to be in, and then use each of the axis instances that are created to plot what you want to like normal. You can have them arranged vertically or horizontally