Docsity

Creating a Line Graph of Life Expectancy for Males and Females in the US, Slides of Econometrics and Mathematical Economics

Partial preview of the text

Download Creating a Line Graph of Life Expectancy for Males and Females in the US and more Slides Econometrics and Mathematical Economics in PDF only on Docsity!

Making Professional Graphs

OBJECTIVES The main objectives are: ™In depth analysis of line graph ™In depth analysis of scatter graph ™Working with^ labels,^ legend^

and^ other

graphing options.

Line Graphs To get the same^ graph,^ we^ can^ simply

write^ the

previous command as follows: line^ le_female le_male year

80 70 60 50 40 1900 1920 1940 1960

(^1980 2000) YearLife expectancy, females Life expectancy, males

The^ same^ Graph^ is shown.

Line Graphs We can modify the ‘X labels’ and ‘Y labels’.For ‘X labels’, type the command: line le_male le_female year, xlabel(1900(10)2000) 80 70 60 50 40 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990

(^2000) Year Life expectancy, males^ Life expectancy, females

Line Graphs We can do the same for the ‘Y-axis’. 80 70 60 50 40 1900 1910 1920 1930 1940 1950 1960 1970 1980

(^1990 2000) YearLife expectancy, males Life expectancy, females

line le_male le_female year, xlabel(1900(10)2000)xtic(1900(5)2000) ylabel(35(10)80) ytic(35(5)80)

Line Graphs Add a title to your graph.For this just add the title commands at the end of yourgraph.The command is: line le_male le_female year, xlabel(1900(10)2000)xtic(1900(5)2000) ylabel(35(10)80) ytic(35(5)80)title("LIFE EXPECTANCY OF MALES &FEMALES OF US ") xtitle("NO OF YEARS")ytitle("LIFE EXPECTANCY")

10

Line Graphs The graph is shown below: 75 65 55 LIFE EXPECTANCY 45 35 1900 1910 1920 1930 1940 1950 1960 1970 1980

(^1990 2000) NO OF YEARS LIFE EXPECTANCY OF MALES & FEMALES OF USLife expectancy, males^ Life expectancy, females

11

Line Graphs We can also adjust the size of the titles and also their marginfrom the graph.Just type the following command: line le_male le_female^ year,^ xlabel(1900(10)2000)xtic(1900(5)2000) ylabel(35(10)80)^ ytic(35(5)80)

title("LIFE EXPECTANCY OF MALES & FEMALES OF US ", size(large)margin(medium))^ xtitle("NO

OF^ YEARS",^ size(medium) margin(small))^ ytitle("LIFE

EXPECTANCY",^ size(medium) margin(small))

13

Line Graphs Now make the X and Y labels small. i.e. make the font of xlabels (1900, …etc) small. line le_male le_female^ year,^ xlabel(1900(10)2000,

labs(small)) xtic(1900(5)2000)^ ylabel(35(10)

,^ labs(small) )^ ytic(35(5)80) title("LIFE EXPECTANCY OF MALES & FEMALES OF US ",size(large)^ margin(medium))

xtitle("NO^ OF^ YEARS", size(medium)^ margin(small))

ytitle("LIFE^ EXPECTANCY", size(medium) margin(small))

14

Line Graphs The graph is shown below: 75 65 55 45 LIFE EXPECTANCY 35 1900 1910 1920 1930 1940 1950 1960 1970 1980

(^1990 2000) NO OF YEARS LIFE EXPECTANCY OF MALES & FEMALES OF USLife expectancy, males^ Life expectancy, females

16

Line GraphsThe Stata command is: line le_male le_female^ year,^ xlabel(1900(10)2000,

labs(small)) xtic(1900(5)2000)^ ylabel(35(10)80,

labs(small))^ ytic(35(5)80) title("LIFE EXPECTANCY OF MALES & FEMALES OF US ",size(large)^ margin(medium))

xtitle("NO^ OF^ YEARS", size(medium)^ margin(small))

ytitle("LIFE^ EXPECTANCY", size(medium) margin(small)) leg(pos(6)) Try the following options for the legends: leg(pos(9))leg(pos(3))leg(pos(-3))(Note: The last command will use the default value b/c -3 is out ofrange).

17

Line Graphs The graph is shown: 75 65 55 45 LIFE EXPECTANCY 35 1900 1910 1920 1930 1940 1950 1960 1970

(^1980 1990 2000) NO OF YEARSLife expectancy, males Life expectancy, females LIFE EXPECTANCY OF MALES & FEMALES OF US

19

Line Graphs The graph is shown below: 75 65 55 45 LIFE EXPECTANCY 35 1900 1910 1920 1930 1940 1950 1960 1970

(^1980 1990 2000) NO OF YEARSLife expectancy, malesLife expectancy, females LIFE EXPECTANCY OF MALES & FEMALES OF US

20

Line GraphsYou can also stack the legends one above the other byusing the command: line le_male le_female^ year,^ xlabel(1900(10)2000,

labs(small)) xtic(1900(5)2000)^ ylabel(35(10)80,

labs(small))^ ytic(35(5)80) title("LIFE EXPECTANCY OF MALES & FEMALES OF US ",size(large)^ margin(medium))

xtitle("NO^ OF^ YEARS", size(medium)^ margin(small))

ytitle("LIFE^ EXPECTANCY", size(medium) margin(small)) leg(col(1) stack pos(6))