Fun with maps in Stata

Today I was toying with Kevin Crow’s -shp2dta- and Maurizio Pisati’s -spmap-. -shp2dta- transforms spatial datasets in shapefile format into Stata data format and -spmap- graphs data onto maps. For starters, I browsed through Stata’s FAQ on -spmap- and Friedrich Huebler’s blog post “Guide to creating maps with Stata”, where instructions are clearly detailed. And, [...]

Functions and marker symbols

Stata’s -graph twoway function- draws the line plot of a specified function. Example, the half of a parabola with the equation y = x^2 can be drawn by typing: tw function y = 4*x^2 The default is that the function is drawn over the range [0,1]. If you want to draw the other side of [...]

Combining charts

You can combine separate Stata graphs into one graph by using -combine-. We will illustrate how this works using census.dta included in Stata. Figure 1 below is the combination of three separate graphs. How was Figure 1 created? sysuse census.dta /* First, create separate graphs and and store each of them into memory by using [...]

Graph Recorder: how it works

The graph recorder records all edits that you make in the graph editor so that you can apply the same edits on other charts without manually going through the same process over and over again. Once you click the Start Recording button , all the clicking and typing that you do within the graph editor [...]

The order() suboption makes label() redundant

Before, I thought that the order() suboption for graphic legend() option is only used to specify which legend keys will be shown and in which order you want them to be displayed. But recently I learned that it also makes the label() suboption redundant. To illustrate, we use census.dta which is installed with Stata. sysuse [...]

Writing Greek letters and other symbols in graphs

Greek letters, math symbols, and other symbols (such as Copyright and Trademark symbols) can be incorporated in Stata graphs with the use of SMCL tags. SMCL (Stata Markup and Control Language; pronounced as “smickle”) is used to modify all text output in Stata. The tag for Greek letters or symbols are of the form {&name}. [...]

Drawing scatter plots

The graph command -twoway scatter- (or -tw scatter-) draws scatter plots. Here we draw the scatter plots of the share of electronics in total export of the Philippines and Malaysia over time. In Figure 0, we draw a scatter plot of Philippine export shares in electronics. If not specified, Stata will use default options for [...]

Color palette

There is no better way to choose colors than to see the actual colors, not just the list of colors as in those you get when you type: help colorstyle Stata has a built-in color viewer -palette color-, but this command can only show you upto two colors: Figure 1 results from typing: palette color [...]

Stacked bars

-graph bar- and -graph twoway bar- draw Stata (vertical) bar charts. -graph bar- draws bar charts over a categorical X variable and has more options than -graph twoway bar-, which draws bar charts with numerical X and Y values. Here, we use -graph bar- to draw stack bar graphs (figures 1 and 2). In figure [...]

-histogram- and the -addplot- option

The beauty of Stata graphics lies in their flexibility—they can be highly customized. To illustrate, the histogram of proximity (right photo) was drawn using the command: #delimit ; histogram proximity, bcolor(ltblue) width(0.025) start(0) freq addplot(histogram proximity if proximity>0.4, bcolor(yellow) width(0.025) start(0) freq || histogram proximity if proximity>0.55, bcolor(blue) width(0.025) start(0) freq || histogram proximity if proximity>0.65, bcolor(red) width(0.025) start(0) freq) ytitle(“Number [...]

Follow

Get every new post delivered to your Inbox.

Join 48 other followers