|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "3c1ab515-e765-48f5-bfaf-35d4f95581fd", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Figures for Lake Model Lecture" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "code", |
| 13 | + "execution_count": 1, |
| 14 | + "id": "45727b3e-f531-4a31-b838-840ccf9d3c02", |
| 15 | + "metadata": {}, |
| 16 | + "outputs": [ |
| 17 | + { |
| 18 | + "name": "stdout", |
| 19 | + "output_type": "stream", |
| 20 | + "text": [ |
| 21 | + "Requirement already satisfied: graphviz in /Users/mmcky/anaconda3/envs/quantecon/lib/python3.11/site-packages (0.20.3)\n" |
| 22 | + ] |
| 23 | + } |
| 24 | + ], |
| 25 | + "source": [ |
| 26 | + "!pip install graphviz" |
| 27 | + ] |
| 28 | + }, |
| 29 | + { |
| 30 | + "cell_type": "code", |
| 31 | + "execution_count": 2, |
| 32 | + "id": "68e95ec8-877e-416a-a8ff-665715dfe222", |
| 33 | + "metadata": {}, |
| 34 | + "outputs": [], |
| 35 | + "source": [ |
| 36 | + "from graphviz import Digraph" |
| 37 | + ] |
| 38 | + }, |
| 39 | + { |
| 40 | + "cell_type": "code", |
| 41 | + "execution_count": 5, |
| 42 | + "id": "92a57207-4d79-4d7b-98c2-aea1a1e35f57", |
| 43 | + "metadata": {}, |
| 44 | + "outputs": [ |
| 45 | + { |
| 46 | + "data": { |
| 47 | + "text/plain": [ |
| 48 | + "'lake_model_worker.png'" |
| 49 | + ] |
| 50 | + }, |
| 51 | + "execution_count": 5, |
| 52 | + "metadata": {}, |
| 53 | + "output_type": "execute_result" |
| 54 | + } |
| 55 | + ], |
| 56 | + "source": [ |
| 57 | + "# Create Digraph object\n", |
| 58 | + "G = Digraph(format='png')\n", |
| 59 | + "G.attr(rankdir='LR')\n", |
| 60 | + "\n", |
| 61 | + "# Add nodes\n", |
| 62 | + "G.attr('node', shape='circle')\n", |
| 63 | + "G.node('1', 'New entrants', color='blue')\n", |
| 64 | + "G.node('2', 'Unemployed')\n", |
| 65 | + "G.node('3', 'Employed')\n", |
| 66 | + "\n", |
| 67 | + "# Add edges\n", |
| 68 | + "G.edge('1', '2', label='b')\n", |
| 69 | + "G.edge('2', '3', label='λ(1-d)')\n", |
| 70 | + "G.edge('3', '2', label='α(1-d)')\n", |
| 71 | + "G.edge('2', '2', label='(1-λ)(1-d)')\n", |
| 72 | + "G.edge('3', '3', label='(1-α)(1-d)')\n", |
| 73 | + "\n", |
| 74 | + "# Save Plot\n", |
| 75 | + "G.render(filename='lake_model_worker')" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": null, |
| 81 | + "id": "f6c2af58-4d38-44c3-adb0-d1a92a344e51", |
| 82 | + "metadata": {}, |
| 83 | + "outputs": [], |
| 84 | + "source": [] |
| 85 | + } |
| 86 | + ], |
| 87 | + "metadata": { |
| 88 | + "kernelspec": { |
| 89 | + "display_name": "Python 3 (ipykernel)", |
| 90 | + "language": "python", |
| 91 | + "name": "python3" |
| 92 | + }, |
| 93 | + "language_info": { |
| 94 | + "codemirror_mode": { |
| 95 | + "name": "ipython", |
| 96 | + "version": 3 |
| 97 | + }, |
| 98 | + "file_extension": ".py", |
| 99 | + "mimetype": "text/x-python", |
| 100 | + "name": "python", |
| 101 | + "nbconvert_exporter": "python", |
| 102 | + "pygments_lexer": "ipython3", |
| 103 | + "version": "3.11.7" |
| 104 | + } |
| 105 | + }, |
| 106 | + "nbformat": 4, |
| 107 | + "nbformat_minor": 5 |
| 108 | +} |
0 commit comments