Complete the code to add a title to the plot.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1]('My Plot') plt.show()
The title function adds a title to the plot.
Complete the code to add grid lines to the plot.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.[1](True) plt.show()
The grid(True) function adds grid lines to the plot for better readability.
Fix the error in the code to set x-axis label correctly.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.xlabel[1]('Time (s)') plt.show()
The xlabel function requires parentheses to pass the label string.
Fill both blanks to create a scatter plot with red color and circle markers.
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5, 6] plt.scatter(x, y, color=[1], marker=[2]) plt.show()
The color parameter sets the color, and marker='o' sets circle markers.
Fill all three blanks to create a histogram with 10 bins, green color, and alpha transparency 0.5.
import matplotlib.pyplot as plt data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] plt.hist(data, bins=[1], color=[2], alpha=[3]) plt.show()
The bins parameter controls the number of bars, color sets the bar color, and alpha sets transparency.
