![]() ![]() Subplots () are used to create a figure and a subplot. #Adding sub plot using subplots methodį, (ax1, ax2) = plt.subplots(1, 2, sharey=True)įig, axs = plt.subplots(2, 2,sharey=True) The example of creating one, two, and four subplots are shown below. We can use the subplots method to create multiple subplots. Plt.show() Multiple Subplots Creating Multiple Subplots Using Subplots Method. Example showing four subplots in the figure # Adding Subplot to the figure The set_edgecolor method is used to set the color. The reader should have the understanding to check the methods according to the requirement. We intend to provide the understanding, not to explain to you the methods.Įxplaining all methods is not possible. This understanding of the figure and subplot is very important. Would you please take a look at the documentation? This reference will help you a lot when you are writing code on your own. We can change the options of the figure using the methods of the Figure object. Plt.show() Edge Color Using Figure Object Change Edge Colour Using Methods of Figure Object #edge color using methods of Figure objectįig=plt.figure(num=1,facecolor="green",linewidth=4)# open a new figure The color is not visible because the line width is zero. Suppose we apply edge color without changing the line width. By default line width of the figure is zero. The parameter line width is changed to 4. Plt.figure(num=1,facecolor="green",linewidth=4,edgecolor='red')# open a new figure The change in line width and edge color is given in the program below. The third number shows the position in our 2X2 division. I.e., we have four divisions in the figure. the first 2 shows rows, and the second 2 shows columns. The first subplot method is given number 221. Let’s understand the values given in the subplot method. The reader should concentrate on the values given in the subplot method. In the above example, we created two subplots in the same figure. Plt.figure(num=1) # Taking a one more figure because num is given 2 Would you please check the output of the two figures created in the program? Example of using the same figure # using the existing figure We discuss those axes methods and the value 221 used in the subplot in a minute. With this axes object, we have many methods to modify the axes. The subplot method will return an axes object. We use the subplot method to create a coordinate axis in the figure. ![]() In our example, we have given green face color to the figure. The face color parameter is used to give a color to the figure. If the number is not given, python will take its number. We can use that number to represent the same figure in the future code. The parameter num is used to assign a unique number to the figure. In the above program, we created a figure object using plt. Plt.figure(num=2) # Taking a one more figure because num is given 2 Plt.figure(num=1,facecolor="green")# open a new figure To understand better, we take an example program given below. The reader will get clarity about creating multiple subplots in the figure and about axes in the figure. To create the axes, we use the subplot method. We can create multiple coordinate axes in one figure. Whenever we create a figure object, we can place coordinate axes in the figure and plot the graphs. The function Figure is used to construct the graphs. In this class, we will go deep into the functions figure and subplot. In our previous classes, we had a basic idea about Figures. The reader should have prior knowledge of bar and line charts. In this class, we discuss Figure and Subplot in Matplotlib. ![]()
0 Comments
Leave a Reply. |