Skip to content

Instantly share code, notes, and snippets.

@bbdaniels
Created September 13, 2018 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbdaniels/18e1f953018b7ba13c1a4ed0fde0861d to your computer and use it in GitHub Desktop.
Save bbdaniels/18e1f953018b7ba13c1a4ed0fde0861d to your computer and use it in GitHub Desktop.
ietest
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"use https://github.com/worldbank/Stata-IE-Visual-Library/raw/master/Library/Bar%20plots/Bar%20plot%20of%20two%20variables%20by%20treatment/data.dta"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>treated</th>\n",
" <th>w_total_val_inputs_a</th>\n",
" <th>w_total_val_harvested_a</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Control</td>\n",
" <td>36000</td>\n",
" <td>64000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Treated</td>\n",
" <td>16340</td>\n",
" <td>12800</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Control</td>\n",
" <td>68100</td>\n",
" <td>19350</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Treated</td>\n",
" <td>36000</td>\n",
" <td>42000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Treated</td>\n",
" <td>6500</td>\n",
" <td>25000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Treated</td>\n",
" <td>29960</td>\n",
" <td>25000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Treated</td>\n",
" <td>15000</td>\n",
" <td>37500</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Treated</td>\n",
" <td>26000</td>\n",
" <td>70000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Treated</td>\n",
" <td>33500</td>\n",
" <td>125000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Treated</td>\n",
" <td>24500</td>\n",
" <td>37500</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"\n",
" +-------------------------------+\n",
" | treated w_to~s_a w_to~d_a |\n",
" |-------------------------------|\n",
" 1. | Control 36000 64000 |\n",
" 2. | Treated 16340 12800 |\n",
" 3. | Control 68100 19350 |\n",
" 4. | Treated 36000 42000 |\n",
" 5. | Treated 6500 25000 |\n",
" |-------------------------------|\n",
" 6. | Treated 29960 25000 |\n",
" 7. | Treated 15000 37500 |\n",
" 8. | Treated 26000 70000 |\n",
" 9. | Treated 33500 125000 |\n",
" 10. | Treated 24500 37500 |\n",
" +-------------------------------+\n",
"\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%head"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"delimiter now ;"
]
}
],
"source": [
"#d;"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
". graph bar w_total_val_harvested_a w_total_val_inputs_a, over(treated) ba\n",
"> rgap(-30) legend(label(1 \"Total Value Harvested\") label(2 \"Total Value Inp\n",
"> uts\")) bar (1, color(\"0 102 102\") ) bar (2, color(\"153 0 76\") ) ytit\n",
"> le (\"Value in RWF\") title (\"Harvested value and Input Value\") subtitle (\n",
"> \"By treatment\") note (\"Note: Variables are winsorized at 0.01\")\n",
"\n",
". noi graph export /Users/bbdaniels/.stata_kernel_cache/graph${stata_kernel_gra\n",
"> ph_counter}.svg, width(600) replace\n"
]
},
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!-- This is a Stata 15.1 generated SVG file (http://www.stata.com) -->\n",
"\n",
"<svg version=\"1.1\" width=\"600px\" height=\"436px\" viewBox=\"0 0 3960 2880\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\t<desc>Stata Graph - Graph</desc>\n",
"\t<rect x=\"0\" y=\"0\" width=\"3960\" height=\"2880\" style=\"fill:#EAF2F3;stroke:none\"/>\n",
"\t<rect x=\"0.00\" y=\"0.00\" width=\"3959.88\" height=\"2880.00\" style=\"fill:#EAF2F3\"/>\n",
"\t<rect x=\"2.88\" y=\"2.88\" width=\"3954.12\" height=\"2874.24\" style=\"fill:none;stroke:#EAF2F3;stroke-width:5.76\"/>\n",
"\t<rect x=\"390.80\" y=\"419.90\" width=\"3468.22\" height=\"1829.21\" style=\"fill:#FFFFFF\"/>\n",
"\t<rect x=\"393.68\" y=\"422.78\" width=\"3462.46\" height=\"1823.45\" style=\"fill:none;stroke:#FFFFFF;stroke-width:5.76\"/>\n",
"\t<line x1=\"390.80\" y1=\"2249.10\" x2=\"3859.02\" y2=\"2249.10\" style=\"stroke:#EAF2F3;stroke-width:8.64\"/>\n",
"\t<line x1=\"390.80\" y1=\"1673.03\" x2=\"3859.02\" y2=\"1673.03\" style=\"stroke:#EAF2F3;stroke-width:8.64\"/>\n",
"\t<line x1=\"390.80\" y1=\"1096.83\" x2=\"3859.02\" y2=\"1096.83\" style=\"stroke:#EAF2F3;stroke-width:8.64\"/>\n",
"\t<line x1=\"390.80\" y1=\"520.76\" x2=\"3859.02\" y2=\"520.76\" style=\"stroke:#EAF2F3;stroke-width:8.64\"/>\n",
"\t<rect x=\"637.68\" y=\"1205.61\" width=\"730.87\" height=\"1043.49\" style=\"fill:#006666\"/>\n",
"\t<rect x=\"640.56\" y=\"1208.49\" width=\"725.11\" height=\"1037.73\" style=\"fill:none;stroke:#006666;stroke-width:5.76\"/>\n",
"\t<rect x=\"1149.27\" y=\"1420.82\" width=\"730.87\" height=\"828.28\" style=\"fill:#99004C\"/>\n",
"\t<rect x=\"1152.15\" y=\"1423.70\" width=\"725.11\" height=\"822.52\" style=\"fill:none;stroke:#99004C;stroke-width:5.76\"/>\n",
"\t<rect x=\"2369.69\" y=\"614.19\" width=\"730.87\" height=\"1634.91\" style=\"fill:#006666\"/>\n",
"\t<rect x=\"2372.57\" y=\"617.07\" width=\"725.11\" height=\"1629.15\" style=\"fill:none;stroke:#006666;stroke-width:5.76\"/>\n",
"\t<rect x=\"2881.27\" y=\"1037.92\" width=\"730.87\" height=\"1211.18\" style=\"fill:#99004C\"/>\n",
"\t<rect x=\"2884.15\" y=\"1040.80\" width=\"725.11\" height=\"1205.42\" style=\"fill:none;stroke:#99004C;stroke-width:5.76\"/>\n",
"\t<line x1=\"390.80\" y1=\"2249.10\" x2=\"390.80\" y2=\"419.90\" style=\"stroke:#000000;stroke-width:5.76\"/>\n",
"\t<line x1=\"390.80\" y1=\"2249.10\" x2=\"350.83\" y2=\"2249.10\" style=\"stroke:#000000;stroke-width:5.76\"/>\n",
"\t<text x=\"300.72\" y=\"2249.10\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\" transform=\"rotate(-90 300.72,2249.10)\" text-anchor=\"middle\">0</text>\n",
"\t<line x1=\"390.80\" y1=\"1673.03\" x2=\"350.83\" y2=\"1673.03\" style=\"stroke:#000000;stroke-width:5.76\"/>\n",
"\t<text x=\"300.72\" y=\"1673.03\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\" transform=\"rotate(-90 300.72,1673.03)\" text-anchor=\"middle\">20,000</text>\n",
"\t<line x1=\"390.80\" y1=\"1096.83\" x2=\"350.83\" y2=\"1096.83\" style=\"stroke:#000000;stroke-width:5.76\"/>\n",
"\t<text x=\"300.72\" y=\"1096.83\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\" transform=\"rotate(-90 300.72,1096.83)\" text-anchor=\"middle\">40,000</text>\n",
"\t<line x1=\"390.80\" y1=\"520.76\" x2=\"350.83\" y2=\"520.76\" style=\"stroke:#000000;stroke-width:5.76\"/>\n",
"\t<text x=\"300.72\" y=\"520.76\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\" transform=\"rotate(-90 300.72,520.76)\" text-anchor=\"middle\">60,000</text>\n",
"\t<text x=\"190.71\" y=\"1334.56\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\" transform=\"rotate(-90 190.71,1334.56)\" text-anchor=\"middle\">Value in RWF</text>\n",
"\t<line x1=\"390.80\" y1=\"2249.10\" x2=\"3859.02\" y2=\"2249.10\" style=\"stroke:#000000;stroke-width:5.76\"/>\n",
"\t<text x=\"1258.91\" y=\"2359.13\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\" text-anchor=\"middle\">Control</text>\n",
"\t<text x=\"2990.91\" y=\"2359.13\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\" text-anchor=\"middle\">Treated</text>\n",
"\t<text x=\"408.00\" y=\"2737.89\" style=\"font-family:'Helvetica';font-size:79.94px;fill:#000000\">Note: Variables are winsorized at 0.01</text>\n",
"\t<text x=\"2124.91\" y=\"369.63\" style=\"font-family:'Helvetica';font-size:110.01px;fill:#000000\" text-anchor=\"middle\">By treatment</text>\n",
"\t<text x=\"2124.91\" y=\"215.98\" style=\"font-family:'Helvetica';font-size:139.96px;fill:#1E2D53\" text-anchor=\"middle\">Harvested value and Input Value</text>\n",
"\t<rect x=\"651.79\" y=\"2443.64\" width=\"2946.24\" height=\"186.50\" style=\"fill:#FFFFFF\"/>\n",
"\t<rect x=\"654.67\" y=\"2446.52\" width=\"2940.48\" height=\"180.74\" style=\"fill:none;stroke:#000000;stroke-width:5.76\"/>\n",
"\t<rect x=\"694.98\" y=\"2486.96\" width=\"374.47\" height=\"99.99\" style=\"fill:#006666\"/>\n",
"\t<rect x=\"697.86\" y=\"2489.84\" width=\"368.71\" height=\"94.23\" style=\"fill:none;stroke:#006666;stroke-width:5.76\"/>\n",
"\t<rect x=\"2289.99\" y=\"2486.96\" width=\"374.34\" height=\"99.99\" style=\"fill:#99004C\"/>\n",
"\t<rect x=\"2292.87\" y=\"2489.84\" width=\"368.58\" height=\"94.23\" style=\"fill:none;stroke:#99004C;stroke-width:5.76\"/>\n",
"\t<text x=\"1129.34\" y=\"2571.98\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\">Total Value Harvested</text>\n",
"\t<text x=\"2724.36\" y=\"2571.98\" style=\"font-family:'Helvetica';font-size:99.99px;fill:#000000\">Total Value Inputs</text>\n",
"</svg>\n"
],
"text/plain": [
"This front-end cannot display the desired image type."
]
},
"metadata": {
"image/svg+xml": {
"height": 436,
"width": 600
}
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
". global stata_kernel_graph_counter = $stata_kernel_graph_counter + 1\n"
]
}
],
"source": [
"graph bar w_total_val_harvested_a w_total_val_inputs_a, \n",
"\t over(treated)\t\t\n",
"\t bargap(-30)\n",
"\t legend(label(1 \"Total Value Harvested\")\n",
"\t\t\t label(2 \"Total Value Inputs\"))\n",
"\t bar (1, color(\"0 102 102\") ) \n",
"\t bar (2, color(\"153 0 76\") ) \n",
"\t ytitle (\"Value in RWF\")\t\n",
"\t title (\"Harvested value and Input Value\")\n",
"\t subtitle (\"By treatment\")\n",
"\t note (\"Note: Variables are winsorized at 0.01\");\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"delimiter now cr"
]
}
],
"source": [
"#d cr"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Stata",
"language": "stata",
"name": "stata"
},
"language_info": {
"file_extension": ".do",
"mimetype": "text/x-stata",
"name": "stata"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment