Question
Suppose the object y consists of values and the object x consists of their labels. Then following code creates a plot of y over x.
Suppose the object y consists of values and the object x consists of their labels. Then following code creates a plot of y over x. If x is time labels, then the plot will be a line graph.
fig = plt.figure(figsize=(15, 10)) plt.plot(x, y, label = 'label1') plt.legend(loc="upper right") plt.grid() plt.show()
Here label1 is the text used in the legend. The legend will be placed on the upper-right corner of the figure. If you want to plot another values z over x in the same figure, you can simply add
plt.plot(x,z, label = 'label2')
next to plot.plot(x,y).
Use the data frame df to create a figure that includes the line graphs for yield rates over time for all 11 maturities. Used date as the variable for the x-axis.
The resulting graph must be as follows:
Hint: Replace the ????? part with your solution.
fig = plt.figure(figsize=(15, 10)) for i in ?????: plt.plot(?????, ?????, label=?????) plt.legend(loc="upper right") plt.grid() plt.show()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started