-
Introduction 4
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
-
Production Possibilities Frontier 4
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
-
Trade 3
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
-
Demand 4
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Lecture4.4
-
-
Supply 2
-
Lecture5.1
-
Lecture5.2
-
-
Equilibrium 4
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
-
Curve Movements 4
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
Lecture7.4
-
-
Elasticity and Revenue 5
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Lecture8.4
-
Lecture8.5
-
-
Taxes 7
-
Lecture9.1
-
Lecture9.2
-
Lecture9.3
-
Lecture9.4
-
Lecture9.5
-
Lecture9.6
-
Lecture9.7
-
-
Consumer and Producer Surplus 8
-
Lecture10.1
-
Lecture10.2
-
Lecture10.3
-
Lecture10.4
-
Lecture10.5
-
Lecture10.6
-
Lecture10.7
-
Lecture10.8
-
-
Imports and Exports 4
-
Lecture11.1
-
Lecture11.2
-
Lecture11.3
-
Lecture11.4
-
-
Tariffs 2
-
Lecture12.1
-
Lecture12.2
-
The Demand Schedule
Solution
prices = []
hamburgers = []
for price in range(0,11):
prices += [price]
hamburgers += [10-price]
import matplotlib.pyplot as plt
plt.plot(hamburgers,prices)
plt.xlabel("Quantity Demanded")
plt.ylabel("Price")
plt.show()
Nothing here is new. This is what the basic demand graph in economics looks like.
Now let’s talk about the aggregate demand curve. This is the demand curve of all the people put together. Let’s say the person from before is still here, but now we also have a person that has demand as so: 10 at a price of 0, but his demand goes down by 2 every dollar increase.
Let’s graph both their demand schedules, and then add them together to get the aggregate demand schedule. Before we do this, we need to learn about a new function, max(). max() gets us the maximum of two numbers. Why are we going to need this? Person 2 will have negative demand once the price is greater than 5, which makes no sense, so we need to use the maximum function to get only numbers greater than or equal 0. max(x,0) will always return a positive number, which is what we need for this.
prices = []
hamburgers = []
for price in range(0,11):
prices += [price]
hamburgers += [10-price]
plt.plot(hamburgers,prices)
plt.xlabel("Quantity Demanded")
plt.ylabel("Price")
plt.title("Tom's Demand for Hamburgers")
plt.show()
prices = []
hamburgers = []
for price in range(0,11):
prices += [price]
hamburgers += [max(10-price*2,0)]
plt.plot(hamburgers,prices)
plt.xlabel("Quantity Demanded")
plt.ylabel("Price")
plt.title("Paul's Demand for Hamburgers")
plt.show()
prices = []
hamburgers = []
for price in range(0,11):
prices += [price]
hamburgers += [(10-price)+max(10-price*2,0)]
plt.plot(hamburgers,prices)
plt.xlabel("Quantity Demanded")
plt.ylabel("Price")
plt.title("Combined Demand for Hamburgers")
plt.show()
You’ll notice the combined demand for the hamburgers is not a straight line. This is because from a price of 10 to 5, only the first person will buy hamburgers, where as at a price of 5 to 0 there is demand from two buyers.
Here is something else to consider about the demand curve, it can shift. Let’s say we have a demand curve with the equation quantity demanded = 15 – price. What happens if all of a sudden there is an increase in demand and the equation is really quantity demanded = 15 – price? We would have a shift to the right. Let’s model it using python.
import matplotlib.pyplot as plt
prices = []
hamburgers = []
for price in range(0,11):
prices += [price]
hamburgers += [15-price]
plt.plot(hamburgers,prices)
prices2 = []
hamburgers2 = []
for price in range(0,11):
prices2 += [price]
hamburgers2 += [20-price]
plt.plot(hamburgers2,prices2)
plt.xlabel("Quantity Demanded")
plt.ylabel("Price")
plt.title("Increased Demand")
ax = plt.axes()
ax.arrow(10.25, 5.25, 2, 2, head_width=0.2, head_length=0.1, fc='k', ec='k')
plt.show()
The first half of the code is the same as before, except we are plotting two demand lines. The first one is our old demand line, the second is our new demand line with the equation 20-p. Now let’s talk about the last six lines. The first three lines of it just set labels for the x axis, y axis and the title. The next two allow us to create an arrow between the demand lines. This arrow is totally extra, we don’t need it, but it is helpful for visualizing which way the curve is shifting. For now, don’t worry about these two lines of codes. The last line displays our plot.