------------------------------------------------------------------------------- help forslideplot-------------------------------------------------------------------------------

Sliding bar plot for frequencies or percents

slideplot{bar|hbar}varname[weight] [ifexp] [inrange],negative(valuelist)positive(valuelist)[by(byvarlist)percentgraph_options]

slideplot{bar|hbar}varlist[weight] [ifexp] [inrange],negative(varlist)positive(varlist)[by(byvarlist)percentgraph_options]

Description

slideplotproduces a sliding bar plot showing frequencies (or optionally percents) of categories using data from one or more variables. The plot is most helpful if these categories can be ordered naturally, at least approximately.The bar plot may be vertical or horizontal. The syntaxes

slideplot barandslideplot hbarare specified to indicate use of graph bar and graph hbar respectively. The choice is a matter of personal taste, although in general horizontal displays make it easier to identify names or labels of categories. Each bar is stacked and each straddles zero. The frequencies or percents shown are plotted as positive or negative.There are two syntaxes. The first is for a long data structure in which categories are recorded in a single variable, which may be numeric or string. The second is for a wide data structure in which frequencies of categories are recorded in two or more variables, which must be numeric.

fweights andaweights may be specified.

Options

negative()andpositive()are required options. With the first syntax, the argument of each is avaluelist, i.e. a numeric list or a list of string values. With the second syntax, it is avarlistof numeric variables.In the first syntax, suppose we have data in a numeric variable

opinionon a 5 point opinion scale which we wish to plot, treating frequencies of 1 and 2 as positive and frequencies of 4 and 5 as negative, and ignoring the frequency of 3. The syntax is, minimally,slideplot hbar opinion, neg(5 4) pos(2 1)orslideplot bar opinion,neg(5 4) pos(2 1). Althoughnegative()andpositive()may be specified in any order, both treat the order of values literally and as specifying the order from left to right or from above to below. Thus the order of bars plotted with this example is 5 4 2 1 with bars for 5 and 4 being plotted on the negative side of 0 and bars for 2 and 1 being plotted on the positive side of 0.Or suppose that we have data in a string variable

candidatewhich we wish to plot in terms of votes for "Bush" (on the right, naturally) and of votes for "Gore" (on the left). The syntax is, minimally,slideplot hbar candidate, neg("Gore") pos("Bush").In the second syntax, suppose we have data in three numeric variables,

Bush,GoreandNader, which we wish to plot. The order might deserve discussion but one possibility isslideplot hbar BushGore Nader, neg(Nader Gore) pos(Bush).

by()specifies that bars are to be shown separately for the distinct combinations ofbyvarlist. This is not a required option but in practice perhaps the most useful handle provided byslideplot. The number of variables inbyvarlistmust not exceed two.

percentstipulates that each bar be plotted in terms of percents of the total. Thusslideplot hbar Bush Gore Nader, neg(Nader Gore) pos(Bush)percentwill show totals for Bush, Gore and Nader as percents of the total for all candidates, whileslideplot hbar Bush Gore, neg(Gore)pos(Bush) percentwill report Bush and Gore as percents of their total.

graph_optionsrefers to options of graph bar or graph hbar.

Examples. use http://www.stata-press.com/data/r8/voter.dta (candidat is 2 for Clinton, 3 for Bush) . slideplot hbar candidat [w=frac], neg(2) pos(3) by(inc) . slideplot hbar candidat [aw=pfrac], neg(2) pos(3) by(inc)

. slideplot hbar answer [w=freq], by(lifecycle car) percent neg(1 2) pos(4 5) ylabel(-60(20)60)

AuthorNicholas J. Cox, University of Durham n.j.cox@durham.ac.uk

Also seeOn-line: help for majority (if installed); catplot (if installed)