3.
test_generate_figure3
Define a numpy array 'x' with expression '[Link](1, 101)'. Define another numpy array 'y1' with
expression 'y1 = x'.
Define another numpy array 'y2' with expression 'y1 = x∗∗2'.
Define another numpy array 'y3' with expression 'y1 = x∗∗3'.
Create a figure of size 8 inches in width, and 6 inches in height. Name it as fig.
Define a grid 'g' of 2 rows and 2 columns, using 'GridSpec' function. Ensure that '[Link]' is
imported, before defining the grid.
Create an axes, using [Link] function. Name it as axes1. The subplot must span the 1st row and 1st
column of the defined grid 'g'. Set 'title' argument to 'y = x'. Draw a line plot of 'x' and 'y1' using 'plot'
function on 'axes1.
Create an axes, using [Link] function. Name it as axes2. The subplot must span 2nd row and 1st
column of defined grid 'g'. Set 'title' argument to 'y = x∗∗2'. Draw a line plot of 'x' and 'y2' using 'plot'
function on 'axes2.
Create an axes, using [Link] function. Name it as axes3. The subplot must span all rows of 2nd column
of defined grid 'g'. Set 'title' argument to 'y = x∗∗3'. Draw a line plot of 'x' and 'y3' using 'plot' function on
'axes3.
Adjust the entire layout with the expression 'plt.tight_layout()'.
In [18]:
import [Link] as plt
import numpy as np
import [Link] as gs
x = [Link](1,101)
y1 = x
y2 = x**2
y3 = x**3
fig = [Link](figsize=(8,6))
g = [Link](2,2)
axes1 = [Link](g[0,0])
[Link](title="y = x")
[Link](x,y1)
axes2 = [Link](g[1,0])
[Link](title="y = x**2")
[Link](x,y2)
axes3 = [Link](g[:,1])
[Link](title="y = x**3")
[Link](x,y3)
plt.tight_layout()