Complete the code to set the x-axis limits from 0 to 10.
import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4]) plt.[1](0, 10) plt.show()
The xlim function sets the limits of the x-axis. Here, it is set from 0 to 10.
Complete the code to set the y-axis limits from -5 to 5.
import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4]) plt.[1](-5, 5) plt.show()
The ylim function sets the limits of the y-axis. Here, it is set from -5 to 5.
Fix the error in the code to set both x and y axis limits correctly.
import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4]) plt.axis([1]) plt.show()
The plt.axis() function accepts a list with four values: [xmin, xmax, ymin, ymax]. The correct order is [0, 10, -5, 5].
Fill both blanks to create a dictionary that sets x-axis limits from 1 to 4 and y-axis limits from 10 to 20.
limits = {'xlim': ([1], [2]), 'ylim': (10, 20)}The dictionary keys 'xlim' and 'ylim' expect tuples with two values each. Here, x-axis limits are set from 1 to 4.
Fill all three blanks to set x-axis limits from 0 to 5 and y-axis limits from -2 to 3 using plt.axis().
import matplotlib.pyplot as plt plt.plot([1, 2, 3]) plt.axis([[1], [2], [3], 3]) plt.show()
The plt.axis() function takes a list of four values: [xmin, xmax, ymin, ymax]. Here, xmin=0, xmax=5, ymin=-2, ymax=3.