![]() The axes of each subplot is scaled in a different way. import matplotlib.pyplot as plt Create a simple plot x 0, 1, 2, 3, 4 y 0, 1, 4, 9, 16 Set the figure size (width, height) in inches plt.figure(figsize(10, 5)) Plot the data plt.plot(x, y) Display the plot plt.show() In this example, we set the figure size to 10 inches in width and 5 inches in height. The code section below builds a 2 row by 2 column array of subplots in one figure. The table below summarizes Matplotlib's axis scaling methods. Matplotlib contains three plotting methods which scale the x and y-axis linearly or logarithmically. ![]() The plot of an exponential function looks different on a linear scale compared to a logarithmic scale. Subplots are useful if you want to show the same data on different scales. If a 2 row by 3 column array of plots is created, the must be arrayed to correspond to these dimensions: fig, ( (ax1,ax2,a3), (ax4,ax5,a圆) ) = plt.subplots(2, 3) If a 2 row by 2 column array of plots is created, the must to be arrayed as shown below: fig, ( (ax1,ax2), (ax3,ax4) ) = plt.subplots(2,2) The needs to have dimensions that correspond to rows and cols. Where rows and cols are integers that control the subplot layout. The general format is: fig, = plt.subplots(rows, cols) The columnwidths argument to makesubplots can be used to customize the relative widths of the columns in a subplot grid. Matplotlib's plt.subplot() function can include two positional arguments for the number of rows of subplots in the figure and the number of columns of subplots in the figure. This can be accomplished using Matplotlib subplots. Sometimes it is useful for problem solvers to include a couple plots in the same figure window. Problem Solving with Python Book Construction
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |