Skip to content

Commit 215e2d9

Browse files
committed
fig: add captions and numbers
1 parent 5e2d75b commit 215e2d9

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

lectures/intro_supply_demand.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ The total height of each bar $i$ is willingness to pay by consumer $i$.
100100
The orange portion of some of the bars shows consumer surplus.
101101

102102
```{code-cell} ipython3
103+
---
104+
mystnb:
105+
figure:
106+
caption: "Willingness to pay (discrete)"
107+
name: wpdisc
108+
---
103109
fig, ax = plt.subplots()
104110
consumers = range(1, 11) # consumers 1,..., 10
105111
# willingness to pay for each consumer
@@ -154,6 +160,12 @@ p = 100 e^{-q}
154160
$$
155161

156162
```{code-cell} ipython3
163+
---
164+
mystnb:
165+
figure:
166+
caption: "Willingness to pay (continuous)"
167+
name: wpcont
168+
---
157169
def inverse_demand(q):
158170
return 100 * np.exp(- q)
159171
@@ -179,6 +191,12 @@ Reasoning by analogy with the discrete case, the area under the demand curve and
179191
The consumer surplus is shaded in the figure below.
180192

181193
```{code-cell} ipython3
194+
---
195+
mystnb:
196+
figure:
197+
caption: "Willingness to pay (continuous) with consumer surplus"
198+
name: wpcont_cs
199+
---
182200
# solve for the value of q where demand meets price
183201
q_star = np.log(100) - np.log(price)
184202
@@ -211,12 +229,18 @@ Having discussed demand, let's now switch over to the supply side of the market.
211229
The figure below shows the price at which a collection of producers, also numbered 1 to 10, are willing to sell one unit of the good in question
212230

213231
```{code-cell} ipython3
232+
---
233+
mystnb:
234+
figure:
235+
caption: "Willingness to sell (discrete)"
236+
name: wsdisc
237+
---
214238
fig, ax = plt.subplots()
215239
producers = range(1, 11) # producers 1,..., 10
216240
# willingness to sell for each producer
217241
wts = (5, 8, 17, 22, 35, 39, 46, 57, 88, 91)
218242
price = 25
219-
ax.bar(producers, wts, label="willingness to sell", color="blue", alpha=0.8)
243+
ax.bar(producers, wts, label="willingness to sell", color="green", alpha=0.5)
220244
ax.set_xlim(0, 12)
221245
ax.set_xticks(producers)
222246
ax.set_ylabel("willingness to sell")
@@ -251,6 +275,12 @@ $$
251275
The shaded area is the total producer surplus in this continuous model.
252276

253277
```{code-cell} ipython3
278+
---
279+
mystnb:
280+
figure:
281+
caption: "Willingness to sell (continuous) with producer surplus"
282+
name: wscont
283+
---
254284
def inverse_supply(q):
255285
return 2 * q**2
256286
@@ -293,6 +323,12 @@ In general, for a function $f$, the **integral** of $f$ over the interval $[a, b
293323
This value is written as $\int_a^b f(x) \mathrm{d} x$ and illustrated in the figure below when $f(x) = \cos(x/2) + 1$.
294324

295325
```{code-cell} ipython3
326+
---
327+
mystnb:
328+
figure:
329+
caption: "Area under the curve"
330+
name: integrate
331+
---
296332
def f(x):
297333
return np.cos(x/2) + 1
298334
@@ -304,8 +340,7 @@ ab_grid = np.linspace(a, b, 400)
304340
fig, ax = plt.subplots()
305341
ax.plot(x_grid, f(x_grid), label="$f$", color="k")
306342
ax.fill_between(ab_grid, [0] * len(ab_grid), f(ab_grid),
307-
label="$\int_a^b f(x) dx$",
308-
color='grey', alpha=0.5)
343+
label="$\int_a^b f(x) dx$")
309344
ax.legend()
310345
plt.show()
311346
```
@@ -388,6 +423,12 @@ def inverse_supply(q, model):
388423
Here is a plot of these two functions using `market`.
389424

390425
```{code-cell} ipython3
426+
---
427+
mystnb:
428+
figure:
429+
caption: "Supply and demand"
430+
name: supply_demand
431+
---
391432
market = create_market()
392433
393434
grid_min, grid_max, grid_size = 0, 1.5, 200
@@ -425,6 +466,12 @@ $$ (eq:cstm_spls)
425466
The next figure illustrates
426467
427468
```{code-cell} ipython3
469+
---
470+
mystnb:
471+
figure:
472+
caption: "Supply and demand (consumer surplus)"
473+
name: supply_demand_cs
474+
---
428475
:tags: [hide-input]
429476
430477
q = 1.25
@@ -485,6 +532,12 @@ $$ (eq:pdcr_spls)
485532
The next figure illustrates
486533
487534
```{code-cell} ipython3
535+
---
536+
mystnb:
537+
figure:
538+
caption: "Supply and demand (producer surplus)"
539+
name: supply_demand_ps
540+
---
488541
:tags: [hide-input]
489542
490543
q = 0.75
@@ -560,6 +613,12 @@ def W(q, market):
560613
The next figure plots welfare as a function of $q$.
561614
562615
```{code-cell} ipython3
616+
---
617+
mystnb:
618+
figure:
619+
caption: "Welfare"
620+
name: wf
621+
---
563622
:tags: [hide-input]
564623
565624
q_vals = np.linspace(0, 1.78, 200)

0 commit comments

Comments
 (0)