Differences between revisions 4 and 7 (spanning 3 versions)
Revision 4 as of 2023-06-07 21:03:52
Size: 240
Comment:
Revision 7 as of 2025-12-17 18:21:09
Size: 973
Comment: Notes
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The '''`graph`''' command generates an external graph file. '''`-graph-`''' renders a visual graph.
Line 15: Line 15:
graph export foo.png
graph save foo // native Stata graphic
graph export foo.png // rendered graphic
Line 17: Line 19:



=== Plotting Aggregated Statistics ===

Consider a time series dataset that includes a time period indicator (`t`) that ranges from 3 to 9, an estimated population proportion (`p`), and upper/lower confidence interval bounds (`ci_upper` and `ci_lower`). This time series can be plotted like:

{{{
tsset t
graph twoway (rarea ci_lower ci_upper t, color(gs15)) (tsline p, ylabel(0(0.05)0.25 tlabel(3(1)9))
}}}

It may be helpful to also plot a horizontal line for the overall mean. Try:

{{{
quietly summ p
generate m = r(mean)
graph twoway ... (tsline m)
}}}

----



== See also ==

[[https://www.stata.com/manuals/dgraph.pdf|Stata manual for -graph-]]

Stata Graph

-graph- renders a visual graph.


Usage

graph hbar foo, over(bar) over(baz) asyvars

graph save foo        // native Stata graphic
graph export foo.png  // rendered graphic

Plotting Aggregated Statistics

Consider a time series dataset that includes a time period indicator (t) that ranges from 3 to 9, an estimated population proportion (p), and upper/lower confidence interval bounds (ci_upper and ci_lower). This time series can be plotted like:

tsset t
graph twoway (rarea ci_lower ci_upper t, color(gs15)) (tsline p, ylabel(0(0.05)0.25 tlabel(3(1)9))

It may be helpful to also plot a horizontal line for the overall mean. Try:

quietly summ p
generate m = r(mean)
graph twoway ... (tsline m)


See also

Stata manual for -graph-


CategoryRicottone

Stata/Graph (last edited 2025-12-17 18:21:09 by DominicRicottone)