sales with exact values for 7 daysdays with exact day namesplt.subplots()ax.plot()ax.set_title()ax.set_xlabel() and ax.set_ylabel()plt.show()sales with exact values for 7 daysdays with exact day namesplt.subplots()ax.plot()ax.set_title()ax.set_xlabel() and ax.set_ylabel()plt.show()sales with these exact values: [150, 200, 170, 220, 180, 210, 190]. Also create a list called days with these exact strings: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].Use square brackets to create lists. Make sure the values and strings match exactly.
plt. Then create a figure and axes using fig, ax = plt.subplots().Use import matplotlib.pyplot as plt to import. Then call plt.subplots() to get figure and axes.
ax.plot() to plot days on the x-axis and sales on the y-axis.Use ax.plot(x, y) where x is days and y is sales.
ax.set_title() to set the title to "Weekly Sales". Use ax.set_xlabel() to label the x-axis as "Day". Use ax.set_ylabel() to label the y-axis as "Sales". Finally, display the plot using plt.show().Use ax.set_title(), ax.set_xlabel(), and ax.set_ylabel() to add labels. Use plt.show() to display the plot.
Why is the Object-Oriented (OO) interface in matplotlib preferred for creating multiple plots?
Which of the following is the correct way to create a figure and axes using the OO interface in matplotlib?
import matplotlib.pyplot as plt # Fill in the blank fig, ax = _____
plt.subplots() to create a figure and axes objects together.plt.figure() creates only a figure, plt.plot() plots data, and plt.show() displays plots.What will be the output of the following code snippet?
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6])
ax.set_title('My Plot')
print(type(ax))AxesSubplot.Identify the error in this code using the OO interface:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6])
plt.title('Wrong Title')
plt.show()ax.set_title().plt.title() relies on pyplot's state tracking, which mixes interfaces and is not recommended for OO usage.plt.title() instead of ax.set_title() is not the proper OO interface usage. -> Option DYou want to create two side-by-side plots with different data and titles using the OO interface. Which code snippet correctly achieves this?
import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 2)
axs[0].plot([1, 2, 3], [4, 5, 6])
axs[0].set_title('First Plot')
axs[1].plot([10, 20, 30], [40, 50, 60])
axs[1].set_title('Second Plot')
plt.show()plt.subplots(1, 2) returns a figure and an array of two axes objects.axs can be used to plot data and set titles independently.plt.show() is called to display the figure with both plots.Pass the test and this pattern moves unknown