跳至內容

Stata/圖形

來自華夏公益教科書


參考文獻

[編輯 | 編輯原始碼]

散點圖

[編輯 | 編輯原始碼]
. clear
. set obs 100
obs was 0, now 100
. gen id = _n 
. gen a = invnorm(uniform())
. gen b = invnorm(uniform()) + a
. gen c = invnorm(uniform()) - 2*a
. sc b c a, msymbol(sh oh) mcolor(cranberry green)
clear
set obs 100

gen x = invnorm(uniform())
gen y = invnorm(uniform()) + x

tw (sc y x)(lfit y x)
tw (sc y x, msymbol(X))(lfit y x)
tw (sc y x, msymbol(D))(lfit y x)
tw (sc y x, msymbol(T))(lfit y x)
tw (sc y x, msymbol(S))(lfit y x)
tw (sc y x, msymbol(+))(lfit y x)
tw (sc y x, msymbol(p))(lfit y x)
tw (sc y x, msymbol(oh))(lfit y x)
tw (sc y x, msymbol(sh))(lfit y x)

標準誤差條形圖

[編輯 | 編輯原始碼]

標準誤差條形圖非常適合顯示置信區間。

. clear
. set obs 100
obs was 0, now 100
. gen id = _n
. expand 10
(900 observations created)
. gen u = id/30 + invnorm(uniform())
. collapse (mean) mean = u (sd) sd = u, by(id) 
. local s = invnorm(.975) * 97,5 percentile of the normal distribution
. serrbar mean sd id , scale(`s')

圖形設定

[編輯 | 編輯原始碼]
  • 符號列表
. palette symbolpalette 


查詢圖形提供所有設定。

. query graphics
    Graphics settings
        set graphics        on
        set scheme          vg_s2c
        set printcolor      automatic  may be automatic, asis, gs1, gs2, gs3
        set copycolor       automatic  may be automatic, asis, gs1, gs2, gs3
        set macgphengine    quartz     may be quartz or quickdraw
        set piccomments     on


  • 方案定義了圖形的總體外觀。
  • 您可以在 Stata 圖形的視覺指南網站上下載更多方案
. net from http://www.stata-press.com/data/vgsg2/
. net install vgsg2

匯出/儲存圖形

[編輯 | 編輯原始碼]

您可以使用圖形匯出命令將圖形匯出為 png、jpg、ps 或 pdf 格式。

. tw sc y x 
. gr export graph.png, replace

請檢視 h gr export 以檢視所有可用圖形裝置的列表。

您也可以使用圖形儲存命令將圖形儲存在 Stata 圖形格式中。此格式只能由 Stata 讀取。


上一篇:資料 索引 下一篇:程式設計
華夏公益教科書