![]() The subplots() function creates a subplot inside a single plot. This function plots several graphs inside a single graph. ![]() If you want to create multiple sub plots in a single figure to show different aspects of a data, then the subplots() function should be used. () is a built-in library function that creates a subplot for the given points and displays the graph as the output. Let us understand the code of the live example which is given below in which we have plotted two sub plots. Let us cover a live example to understand this function in more detail. The output for the above code is as follows: With the given below code snippet, we will create a figure having 2 rows and 2 columns of subplots. Let us understand this method with the help of a few examples: Example 1: It can be an Axes object or an array of Axes objects. The values returned by these function are as follows:įig: This method is used to return the figure layout.Īx: This method is mainly used to return the axes. Matplotlib subplots() Function Returned Values This parameter is used to indicate the dict with keywords passed to the GridSpec constructor that is used to create the grid on which the subplots are placed on. This parameter is used to indicate the dict with keywords that are passed to the add_subplot call which is used to create each subplot. This optional parameter usually contains boolean values with the default is True. To control the sharing of properties among x (sharex) or among y (sharey) axis these parameters are used. The parameter nrows is used to indicate the number of rows and the parameter ncols is used to indicate the number of columns of the subplot grid. Let us discuss the parameters used by this function: ![]() This function mainly returns a figure and an Axes object or also an array of Axes objects. It is basically a wrapper function and which is used to create common layouts of subplots (including the enclosing figure object) in a single call. The basic syntax to use this function is as follows: (nrows, ncols, sharex, sharey, squeeze, subplot_kw, gridspec_kw, **fig_kw) Matplotlib subplots() Function Parameters This function will create a figure and a set of subplots. Various kind of subplots supported by matplotlib is 2x1 vertical, 2x1 horizontal or a 2x2 grid. The main objective of this function is to create a figure with a set of subplots. This function helps in creating common layouts of subplots and it also includes the enclosing figure object, in a single call. The subplots() function in the Matplotlib acts as a utility wrapper. In this tutorial, we will cover the subplots() function in the state-based interface Pyplot in the Matplotlib Library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |