Sub-graphs and sharing of coordinate axes
1. Draw subgraphs of fixed areas

1.1 Draw single subgraph
Using the subplot() function of the pyplot module, you can draw a single subgraph in a planned area.
1 | |

1.2 Demo1: Sales analysis of product A and product B of a factory last year
1 | |

1.3 Draw multiple subgraphs
Using the subplots() function of the pyplot module, you can draw multiple subgraphs at a time in all the planned areas.
1 | |

1.4 Demo2: Analysis on the proportion of people with cats and dogs in some countries
1 | |

2. Draw subgraphs of custom areas
2.1 Draw single subgraph
Using the subplot2grid() function of pyplot module, you can plan the whole canvas into areas with unequal layout, and draw a single sub graph in a selected area.
1 | |

2.2 Demo3: Tiktok user analysis in 2017 and 2018
1 | |

3. Share coordinate axes of subgraphs
3.1 Sharing the coordinate axes of adjacent subgraphs
When you use the subplots() function to draw subgraphs, you can control whether to share the x-axis or y-axis through the sharex or sharey parameters of the function. The sharex or sharey parameter supports any value of false or ‘none’, true or ‘all’, ‘row’ or ‘col’.


1 | |

3.2 Shared axes of non adjacent subgraphs
3.3 Demo4: Relationship between annual temperature and water volume in an area
1 | |

4. Set layout of subgraphs
4.1 Constrained layout
1 | |


4.2 Compact layout
1 | |


4.3 Custom layout
1 | |

1 | |

4.4 Demo5: Sales of a brand of cars in the first half of 2018
1 | |

Sub-graphs and sharing of coordinate axes
https://www.hardyhu.cn/2022/03/17/Sub-graphs-and-sharing-of-coordinate-axes/