Stata Press books

A Visual Guide to Stata Graphics, Second Edition

Michael N. Mitchell
Copyright 2008
ISBN-13: 978-1-59718-039-9
Pages: 471; paperback
Price $57.50
New edition available
See a larger photo of the front cover
See the back cover
Table of contents
Preface to the Second Edition (pdf)
Preface to the First Edition (pdf)
Chapter 1—Introduction (pdf)
Subject index
Download the datasets used in this book

Review of this book from the Stata Journal

Comment from the Stata technical group

Weighing in with 20% more pages than the original, the second edition of A Visual Guide to Stata Graphics is no mere update. Author Michael Mitchell adds coverage of almost every feature added to Stata graphics since the first edition. Foremost among these additions is the interactive Graph Editor, introduced in Stata 10, of which the author says

[...] You need to use the Graph Editor for only a short amount of time to see what a smart and powerful tool it is. Whereas commands offer the power of repeatability, the Graph Editor provides a nimble interface that permits you to tangibly modify graphs like a potter directly handling clay.

Mitchell adds an extensive chapter about the Editor, where he first introduces the Graph Editor then shows it in action. This chapter maintains the overarching style of the book by using over 120 color graphics and screen captures to show exactly how things are done and exactly how they look on the graph. With pictures and words, Mitchell shows you how to change the color, size, or placement of any titles, markers, annotations, or other objects on your graph by using just a few mouse clicks. More subtly, he shows you how to change such things as the number of ticks and labels on your axes, the number of columns in your legends, the label on an individual point, and more. He even shows you how to convert, for example, a scatterplot to a line plot and how to rotate or pivot bar charts. Mitchell also covers such advanced topics as how to draw lines and arrows on graphs so that they continue to reference your objects of interest even if you resize the graph, combine it with other graphs, or change the scale or range of the axes. In short, he exposes all the Graph Editor’s tools, from the simplest to the most powerful. Mitchell does not stop there; almost every example in the book now shows you how to accomplish the desired graph or effect not only by using a command or command-line option but also by using the Graph Editor. Just look for the Editor iconsymbol to learn how to produce the displayed result with the Editor.

Beyond the Graph Editor, Mitchell covers major new features such as time-series axes with intuitive controls for labeling and adding text and lines; panel-data plots; and local polynomial smooths and CIs (which join a host of previously discussed smooths and fits). He also covers more-specific new features such as options for controlling aspect ratios and for changing all text sizes simultaneously.

The book retains its visual style, presenting the reader with a color-coded, visual table of contents that runs along the right edge of every page and shows readers exactly where they are in the book. You can see the color-coded chapter tabs without opening the book, providing quick visual access to each chapter.

The heart of each chapter is a series of entries that are typically formatted three to a page. Each entry shows a graph command (with the emphasized portion of the command highlighted in red), the resulting graph, a description of what is being done, the dataset and scheme used, and, new in the second edition, a section showing how to produce the result by using the Graph Editor. Because every feature, option, and edit is demonstrated with a graph or screen capture, you can often flip through a section of the book to find exactly the effect you are seeking.

Aside from inserting a new second chapter about the Graph Editor, Mitchell retains the original organization of the book. The first chapter discusses how to use the book, the types of Stata graphs, how to use schemes to control the overall appearance of graphs, and how to use options to make specific modifications. He also outlines a process for building graphs using the graph command. The second chapter is a complete overview of the Graph Editor.

Mitchell advisedly spends the most time in his next chapter, which is about twoway graphs such as scatterplots, line plots, area plots, bar plots, range plots, regression fits, and smooths. Mitchell shows how to create each of these types of graphs and how to use options (and the Graph Editor) to control how the graph looks. He also introduces graphing across groups of data; options for adding titles, notes, etc.; and options for adding and controlling legends. Beyond the basics, he shows how to easily overlay plots to obtain such graphs as regression fits with error contours and observed data scatters, local polynomial smooths with scatters of their underlying data, stock-market-style graphs of open and close values with quantities traded as a bar chart at the bottom, histograms with density smooths, and the like. Because Stata’s graph command will let you customize any aspect of the graph, Mitchell spends ample time showing you the most valuable options for obtaining the look you want. After reading this chapter, you will have a thorough grasp on how to create graphs in Stata. Or, if you are in a hurry to discover one special option, you can skim the chapter until you see the effect you want, then glance at the command to see what is highlighted in red.

In the succeeding five chapters, Mitchell covers scatterplot matrices, bar graphs, box plots, dot plots, and pie charts. As with twoway graphs, he shows you how to create each of these graphs and how to adjust every aspect of the graph to your taste (or to a publisher’s required form).

In chapters 9 and 10, Mitchell undertakes an in-depth presentation of the options that are available across almost all graph types—options that add and change the look of titles, notes, and such; control the number of ticks on axes; control the content and appearance of the numbers and labels on axes; control legends; add and change the look of annotations; graph over subgroups; change the look of markers and their labels; apply schemes to control the look of the graph; change the look of graph regions; size graphs and their elements; and more. Again, he now shows how to make these changes both with options and in the Graph Editor.

To complete the graphical journey, Mitchell discusses and demonstrates the 11 styles that unite and control the appearance of the myriad number of graph objects. These styles are angles, colors, clock positions, compass directions, connecting points, line patterns, line widths, margins, marker sizes, orientations, marker symbols, and text sizes.

That completes the main body of the Visual Guide, but don't skip the appendix. There, Mitchell first gives a quick overview of the dozens of statistical graph commands that are not strictly the subject of the book. Even so, these commands use the graph command as an engine to draw their graphs, and therefore almost all that Mitchell has discussed applies to them. To make this clear, he shows explicitly how to apply common options and common Graph Editor tools to statistical graphs. Second, he addresses combining graphs—showing you how to create complex and multipart images from previously created graphs. Third, in a crucial section entitled "Putting it all together", Mitchell shows us how to do just that. We learn more about overlaying twoway plots, and we learn how to combine data management and graphics to create such plots as bar charts of rates with capped confidence intervals, scatterplots with range-finder confidence intervals in both dimensions, and population pyramids. Fourth, Mitchell warns us about mistakes that can be made when typing graph commands and how to correct them. Fifth, he show us how to create our own scheme files. Scheme files allow you to control every aspect of how your graphs look without having to specify options. They are the answer to department or journal standards or if you just want all your graphs to have a common appearance that is not one of the schemes shipped with Stata. As with the rest of the book, this section includes cross-references to the Stata Graphics Reference Manual to provide more depth on the subject. Finally, Mitchell reviews all the datasets, schemes, and other online supplements available for the book.

The second edition of A Visual Guide to Stata Graphics is a complete guide to Stata’s graph command and the associated Graph Editor. Whether you want to tame the Stata graph command, quickly find out how to produce a graphical effect, master the Stata Graph Editor, or learn approaches that can be used to construct custom graphs, this is the book to read.


Table of contents

Dedication
Acknowledgments
Preface to the Second Edition (pdf)
Preface to the First Edition (pdf)
1 Introduction (pdf)
1.1 Using this book
1.2 Types of Stata graphs
1.3 Schemes
1.4 Options
1.5 Building graphs
2 Editor
2.1 Overview of the Graph Editor
2.2 Object Browser
2.3 Modifying objects
2.4 Adding objects
2.5 Moving objects
2.6 Hiding and showing objects
2.7 Locking and unlocking objects
2.8 Using the Graph Recorder
2.9 Graph Editor versus Stata commands
3 Twoway graphs
3.1 Scatterplots
3.2 Regression fits and splines
3.3 Regression confidence interval fits
3.4 Line plots
3.5 Area plots
3.6 Bar plots
3.7 Range plots
3.8 Distribution plots
3.9 Options
3.10 Overlaying plots
4 Scatterplot matrix graphs
4.1 Marker options
4.2 Controlling axes
4.3 Matrix options
4.4 Graphing by groups
5 Bar graphs
5.1 Y variables
5.2 Graphing bars over groups
5.3 Options for controlling gaps between bars
5.4 Options for sorting bars
5.5 Controlling the categorical axis
5.6 Legends and labeling bars
5.7 Controlling the y-axis
5.8 Changing the look of bars
5.9 Graphing by groups
6 Box plots
6.1 Specifying variables and groups
6.2 Options for controlling gaps between boxes
6.3 Options for sorting boxes
6.4 Controlling the categorical axis
6.5 Controlling legends
6.6 Controlling the y axis
6.7 Changing the look of boxes
6.8 Graphing by groups
7 Dot plots
7.1 Specifying variables and groups
7.2 Options for controlling gaps between dots
7.3 Options for sorting dots
7.4 Controlling the categorical axis
7.5 Controlling legends
7.6 Controlling the y axis
7.7 Changing the look of dot rulers
7.8 Graphing by groups
8 Pie charts
8.1 Types of pie charts
8.2 Sorting pie slices
8.3 Changing the look and color and exploding pie slices
8.4 Slice labels
8.5 Controlling legends
8.6 Graphing by groups
9 Options available for most graphs
9.1 Changing the look of markers
9.2 Creating and controlling marker labels
9.3 Connecting points and markers
9.4 Setting and controlling axis titles
9.5 Setting and controlling axis labels
9.6 Controlling axis scales
9.7 Selecting an axis
9.8 Graphing by groups
9.9 Controlling legends
9.10 Adding text to markers and positions
9.11 More options for text and textboxes
10 Standard options available for all graphs
10.1 Creating and controlling titles
10.2 Using schemes to control the look of graphs
10.3 Sizing graphs and their elements
10.4 Changing the look of graph regions
11 Styles for changing the look of graphs
11.1 Angles
11.2 Colors
11.3 Clock position
11.4 Compass direction
11.5 Connecting points
11.6 Line patterns
11.7 Line width
11.8 Margins
11.9 Marker size
11.10 Orientation
11.11 Marker symbols
11.12 Text size
12 Appendix
12.1 Overview of statistical graph commands
12.2 Common options for statistical graphs
12.3 Saving, redisplaying, and combining graphs
12.4 More examples: Putting it altogether
12.5 Common mistakes
12.6 Customizing schemes
12.7 Online supplements
Subject index (pdf)