Contents
Dedication v
Acknowledgments vii
Preface xiii
1 Introduction 1
1.1 Using this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Types of Stata graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.5 Building graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2 Twoway graphs 35
2.1 Scatterplots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.2 Regression fits and splines . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.3 Regression confidence interval (CI) fits . . . . . . . . . . . . . . . . . . . . 50
2.4 Line plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
2.5 Area plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
2.6 Bar plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.7 Range plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.8 Distribution plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
2.9 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
2.10 Overlaying plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3 Scatterplot matrix graphs 95
3.1 Marker options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
3.2 Controlling axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.3 Matrix options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
The electronic form of this book is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.
All rights reserved on the copyright page apply to this document and specifically neither the electronic nor
published form of the book may be distributed or reproduced, either electronically or in printed form.
x Contents
3.4 Graphing by groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
4 Bar graphs 107
4.1 Y-variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
4.2 Graphing bars over groups . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.3 Options for groups, over options . . . . . . . . . . . . . . . . . . . . . . . . 117
4.4 Controlling the categorical axis . . . . . . . . . . . . . . . . . . . . . . . . 123
4.5 Controlling legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
4.6 Controlling the y-axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
4.7 Changing the look of bars, lookofbar options . . . . . . . . . . . . . . . . . 147
4.8 Graphing by groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
5 Box plots 157
5.1 Specifying variables and groups, yvars and over . . . . . . . . . . . . . . . 157
5.2 Options for groups, over options . . . . . . . . . . . . . . . . . . . . . . . . 163
5.3 Controlling the categorical axis . . . . . . . . . . . . . . . . . . . . . . . . 168
5.4 Controlling legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
5.5 Controlling the y-axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
5.6 Changing the look of boxes, boxlook options . . . . . . . . . . . . . . . . . 183
5.7 Graphing by groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
6 Dot plots 193
6.1 Specifying variables and groups, yvars and over . . . . . . . . . . . . . . . 193
6.2 Options for groups, over options . . . . . . . . . . . . . . . . . . . . . . . . 198
6.3 Controlling the categorical axis . . . . . . . . . . . . . . . . . . . . . . . . 202
6.4 Controlling legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
6.5 Controlling the y-axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
6.6 Changing the look of dot rulers, dotlook options . . . . . . . . . . . . . . . 210
6.7 Graphing by groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
7 Pie graphs 217
7.1 Types of pie graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
7.2 Sorting pie slices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
7.3 Changing the look of pie slices, colors, and exploding . . . . . . . . . . . . 221
The electronic form of this book is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.
All rights reserved on the copyright page apply to this document and specifically neither the electronic nor
published form of the book may be distributed or reproduced, either electronically or in printed form.
Contents xi
7.4 Slice labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
7.5 Controlling legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
7.6 Graphing by groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
8 Options available for most graphs 235
8.1 Changing the look of markers . . . . . . . . . . . . . . . . . . . . . . . . . 235
8.2 Creating and controlling marker labels . . . . . . . . . . . . . . . . . . . . 247
8.3 Connecting points and markers . . . . . . . . . . . . . . . . . . . . . . . . 250
8.4 Setting and controlling axis titles . . . . . . . . . . . . . . . . . . . . . . . 254
8.5 Setting and controlling axis labels . . . . . . . . . . . . . . . . . . . . . . . 256
8.6 Controlling axis scales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
8.7 Selecting an axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
8.8 Graphing by groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
8.9 Controlling legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
8.10 Adding text to markers and positions . . . . . . . . . . . . . . . . . . . . . 299
8.11 More options for text and textboxes . . . . . . . . . . . . . . . . . . . . . . 303
9 Standard options available for all graphs 313
9.1 Creating and controlling titles . . . . . . . . . . . . . . . . . . . . . . . . . 313
9.2 Using schemes to control the look of graphs . . . . . . . . . . . . . . . . . 318
9.3 Sizing graphs and their elements . . . . . . . . . . . . . . . . . . . . . . . . 322
9.4 Changing the look of graph regions . . . . . . . . . . . . . . . . . . . . . . 324
10 Styles for changing the look of graphs 327
10.1 Angles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
10.2 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
10.3 Clock position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
10.4 Compass direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
10.5 Connecting points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
10.6 Line patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
10.7 Line width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
10.8 Margins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
10.9 Marker size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
10.10 Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
The electronic form of this book is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.
All rights reserved on the copyright page apply to this document and specifically neither the electronic nor
published form of the book may be distributed or reproduced, either electronically or in printed form.
xii Contents
10.11 Marker symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
10.12 Text size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
11 Appendix 345
11.1 Overview of statistical graph commands, stat graphs . . . . . . . . . . . . 345
11.2 Common options for statistical graphs, stat graph options . . . . . . . . . 352
11.3 Saving and combining graphs, save/redisplay/combine . . . . . . . . . . . 358
11.4 Putting it all together, more examples . . . . . . . . . . . . . . . . . . . . 366
11.5 Common mistakes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
11.6 Customizing schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
11.7 Online supplements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Subject index 383
The electronic form of this book is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.
All rights