SlideShare a Scribd company logo
1 of 1
Download to read offline
graph <plot type> y1
y2
… yn
x [in] [if], <plot options> by(var) xline(xint) yline(yint) text(y x "annotation")BASIC PLOT SYNTAX:
plot sizecustom appearance save
variables: y first plot-specific options facet annotations
titles axes
title("title") subtitle("subtitle") xtitle("x-axis title") ytitle("y axis title") xscale(range(low high) log reverse off noline) yscale(<options>)
<marker, line, text, axis, legend, background options> scheme(s1mono) play(customTheme) xsize(5) ysize(4) saving("myPlot.gph", replace)
CONTINUOUS
DISCRETE
(asis) • (percent) • (count) • over(<variable>, <options: gap(*#) •
relabel • descending • reverse>) • cw •missing • nofill • allcategories •
percentages • stack • bargap(#) • intensity(*#) • yalternate • xalternate
graph hbar draws horizontal bar chartsbar plot
graph bar (count), over(foreign, gap(*0.5)) intensity(*0.5)
bin(#) • width(#) • density • fraction • frequency • percent • addlabels
addlabopts(<options>) • normal • normopts(<options>) • kdensity
kdenopts(<options>)
histogram
histogram mpg, width(5) freq kdensity kdenopts(bwidth(5))
main plot-specific options;
see help for complete set
bwidth • kernel(<options>
normal • normopts(<line options>)
smoothed histogram
kdensity mpg, bwidth(3)
(asis) • (percent) • (count) • (stat: mean median sum min max ...)
over(<variable>, <options: gap(*#) • relabel • descending • reverse
sort(<variable>)>) • cw • missing • nofill • allcategories • percentages
linegap(#) • marker(#, <options>) • linetype(dot | line | rectangle)
dots(<options>) • lines(<options>) • rectangles(<options>) • rwidth
dot plot
graph dot (mean) length headroom, over(foreign) m(1, ms(S))
ssc install vioplot
over(<variable>, <options: total • missing>)>) • nofill •
vertical • horizontal • obs • kernel(<options>) • bwidth(#) •
barwidth(#) • dscale(#) • ygap(#) • ogap(#) • density(<options>)
bar(<options>) • median(<options>) • obsopts(<options>)
violin plot
vioplot price, over(foreign)
over(<variable>, <options: total • gap(*#) • relabel • descending • reverse
sort(<variable>)>) • missing • allcategories • intensity(*#) • boxgap(#)
medtype(line | line | marker) • medline(<options>) • medmarker(<options>)
graph box draws vertical boxplotsbox plot
graph hbox mpg, over(rep78, descending) by(foreign) missing
graph hbar ...
bar plot
graph bar (median) price, over(foreign)
(asis) • (percent) • (count) • (stat: mean median sum min max ...)
over(<variable>, <options: gap(*#) • relabel • descending • reverse
sort(<variable>)>) • cw • missing • nofill • allcategories • percentages
stack • bargap(#) • intensity(*#) • yalternate • xalternate
graph hbar ...grouped bar plot
graph bar (percent), over(rep78) over(foreign)
(asis) • (percent) • (count) • over(<variable>, <options: gap(*#) •
relabel • descending • reverse>) • cw •missing • nofill • allcategories •
percentages • stack • bargap(#) • intensity(*#) • yalternate • xalternatea b c
sort • cmissing(yes | no) • vertical, • horizontal
base(#)
line plot with area shading
twoway area mpg price, sort(price)
17
2 10
23
20
jitter(#) • jitterseed(#) • sort • cmissing(yes | no)
connect(<options>) • [aweight(<variable>)]
scatter plot with labelled values
twoway scatter mpg weight, mlabel(mpg)
jitter(#) • jitterseed(#) • sort
connect(<options>) • cmissing(yes | no)
scatter plot with connected lines and symbols
see also line
twoway connected mpg price, sort(price)
(sysuse nlswide1)
twoway pcspike wage68 ttl_exp68 wage88 ttl_exp88
vertical, • horizontal
Parallel coordinates plot
(sysuse nlswide1)
twoway pccapsym wage68 ttl_exp68 wage88 ttl_exp88
vertical • horizontal • headlabel
Slope/bump plot
SUMMARY PLOTS
twoway mband mpg weight || scatter mpg weight
bands(#)
plot median of the y values
ssc install binscatter
plot a single value (mean or median) for each x value
medians • nquantiles(#) • discrete • controls(<variables>) •
linetype(lfit | qfit | connect | none) • aweight[<variable>]
binscatter weight mpg, line(none)
THREE VARIABLES
mat(<variable) • split(<options>) • color(<color>) • freq
ssc install plotmatrix
regress price mpg trunk weight length turn, nocons
matrix regmat = e(V)
plotmatrix, mat(regmat) color(green)
heatmap
TWO+ CONTINUOUS VARIABLES
bwidth(#) • mean • noweight • logit • adjust
calculate and plot lowess smoothing
twoway lowess mpg weight || scatter mpg weight
FITTING RESULTS
level(#) • stdp • stdf • nofit • fitplot(<plottype>) • ciplot(<plottype>) •
range(# #) • n(#) • atobs • estopts(<options>) • predopts(<options>)
calculate and plot quadriatic fit to data with confidence intervals
twoway qfitci mpg weight, alwidth(none) || scatter mpg weight
level(#) • stdp • stdf • nofit • fitplot(<plottype>) • ciplot(<plottype>) •
range(# #) • n(#) • atobs • estopts(<options>) • predopts(<options>)
calculate and plot linear fit to data with confidence intervals
twoway lfitci mpg weight || scatter mpg weight
REGRESSION RESULTS
horizontal • noci
regress mpg weight length turn
margins, eyex(weight) at(weight = (1800(200)4800))
marginsplot, noci
Plot marginal effects of regression
ssc install coefplot
baselevels • b(<options>) • at(<options>) • noci • levels(#)
keep(<variables>) • drop(<variables>) • rename(<list>)
horizontal • vertical • generate(<variable>)
Plot regression coefficients
regress price mpg headroom trunk length turn
coefplot, drop(_cons) xline(0)
vertical, • horizontal • base(#) • barwidth(#)
bar plot
twoway bar price rep78
vertical, • horizontal • base(#)
dropped line plot
twoway dropline mpg price in 1/5
twoway rarea length headroom price, sort
vertical • horizontal • sort
cmissing(yes | no)
range plot (y1
÷ y2
) with area shading
vertical • horizontal • barwidth(#) • mwidth
msize(<marker size>)
range plot (y1
÷ y2
) with bars
twoway rbar length headroom price
jitter(#) • jitterseed(#) • sort • cmissing(yes | no)
connect(<options>) • [aweight(<variable>)]
scatter plot
twoway scatter mpg weight, jitter(7)
half • jitter(#) • jitterseed(#)
diagonal • [aweights(<variable>)]
scatter plot of each combination of variables
graph matrix mpg price weight, half
y3
y2
y1
dot plot
twoway dot mpg rep78
vertical, • horizontal • base(#) • ndots(#)
dcolor(<color>) • dfcolor(<color>) • dlcolor(<color>)
dsize(<markersize>) • dsymbol(<marker type>)
dlwidth(<strokesize>) • dotextend(yes | no)
ONE VARIABLE sysuse auto, clear
DISCRETE X, CONTINUOUS Y
twoway contour mpg price weight, level(20) crule(intensity)
ccuts(#s) • levels(#) • minmax • crule(hue | chue| intensity) •
scolor(<color>) • ecolor (<color>) • ccolors(<colorlist>) • heatmap
interp(thinplatespline | shepard | none)
3D contour plot
vertical • horizontal
range plot (y1
÷ y2
) with capped lines
twoway rcapsym length headroom price
see also rcap
Laura Hughes (lhughes@usaid.gov) • Tim Essam (tessam@usaid.gov) inspired by RStudio’s awesome Cheat Sheets (rstudio.com/resources/cheatsheets) geocenter.github.io/StataTraining updated January 2016
Disclaimer: we are not affiliated with Stata. But we like it. CC BY NC
Data Visualization
with Stata 14.1 Cheat Sheet
For more info see Stata’s reference manual (stata.com)
Plot Placement
SUPERIMPOSE
graph twoway scatter mpg price in 27/74 || scatter mpg price /*
*/ if mpg < 15 & price > 12000 in 27/74, mlabel(make) m(i)
combine twoway plots using ||
scatter y3 y2 y1 x, marker(i o i) mlabel(var3 var2 var1)
plot several y values for a single x value
graph combine plot1.gph plot2.gph...
combine 2+ saved graphs into a single plot
JUXTAPOSE (FACET)
twoway scatter mpg price, by(foreign, norescale)
total • missing • colfirst • rows(#) • cols(#) • holes(<numlist>)
compact • [no]edgelabel • [no]rescale • [no]yrescal • [no]xrescale
[no]iyaxes • [no]ixaxes • [no]iytick • [no]ixtick [no]iylabel
[no]ixlabel • [no]iytitle • [no]ixtitle • imargin(<options>)

More Related Content

What's hot

Slide thuyết trình quản trị chiến lược chương 6
Slide thuyết trình quản trị chiến lược chương 6Slide thuyết trình quản trị chiến lược chương 6
Slide thuyết trình quản trị chiến lược chương 6Ngọc Hưng
 
Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...
Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...
Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...PinkHandmade
 
Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...
Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...
Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...Nhận Viết Đề Tài Trọn Gói ZALO 0932091562
 
Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...
Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...
Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...Thanh Thanh
 
Câu hỏi quản trị nguồn nhân lực
Câu hỏi quản trị nguồn nhân lựcCâu hỏi quản trị nguồn nhân lực
Câu hỏi quản trị nguồn nhân lựcLinh Pham
 
Bản mô tả công việc(nhom4 ql14 18)
Bản mô tả công việc(nhom4 ql14 18)Bản mô tả công việc(nhom4 ql14 18)
Bản mô tả công việc(nhom4 ql14 18)laithutrang
 
Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ...
 Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ... Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ...
Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ...hieu anh
 
đồ áN môn chi tiết máy thiết kế trạm dẫn động xích tải
đồ áN môn chi tiết máy thiết kế trạm dẫn động xích tảiđồ áN môn chi tiết máy thiết kế trạm dẫn động xích tải
đồ áN môn chi tiết máy thiết kế trạm dẫn động xích tảihttps://www.facebook.com/garmentspace
 
Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...
Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...
Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...Viết thuê trọn gói ZALO 0934573149
 

What's hot (20)

Slide thuyết trình quản trị chiến lược chương 6
Slide thuyết trình quản trị chiến lược chương 6Slide thuyết trình quản trị chiến lược chương 6
Slide thuyết trình quản trị chiến lược chương 6
 
Luận văn: Nâng cao năng lực cạnh tranh của Công ty xây dựng, HAY
Luận văn: Nâng cao năng lực cạnh tranh của Công ty xây dựng, HAYLuận văn: Nâng cao năng lực cạnh tranh của Công ty xây dựng, HAY
Luận văn: Nâng cao năng lực cạnh tranh của Công ty xây dựng, HAY
 
Đề tài hiệu quả kinh doanh công ty xăng dầu, ĐIỂM 8, HOT
Đề tài hiệu quả kinh doanh công ty xăng dầu, ĐIỂM 8, HOTĐề tài hiệu quả kinh doanh công ty xăng dầu, ĐIỂM 8, HOT
Đề tài hiệu quả kinh doanh công ty xăng dầu, ĐIỂM 8, HOT
 
Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...
Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...
Nâng Cao Năng Lực Cạnh Tranh Trong Đấu Thầu Xây Dựng Của Công Ty Cổ Phần Công...
 
Báo Cáo Thực Tập Công Tác Kế Toán Tại Công Ty Xây Dựng.doc
Báo Cáo Thực Tập Công Tác Kế Toán Tại Công Ty Xây Dựng.docBáo Cáo Thực Tập Công Tác Kế Toán Tại Công Ty Xây Dựng.doc
Báo Cáo Thực Tập Công Tác Kế Toán Tại Công Ty Xây Dựng.doc
 
Luận văn: Quản trị nhân lực tại Công ty Bóng đèn Điện Quang, HOT
Luận văn: Quản trị nhân lực tại Công ty Bóng đèn Điện Quang, HOTLuận văn: Quản trị nhân lực tại Công ty Bóng đèn Điện Quang, HOT
Luận văn: Quản trị nhân lực tại Công ty Bóng đèn Điện Quang, HOT
 
Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...
Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...
Nghiên cứu các yếu tố ảnh hưởng đến hành vi mua smartphone của sinh viên tại ...
 
Luận văn Thạc sĩ Giải pháp nhằm hoàn thiện công tác marketing tại Công Ty TNH...
Luận văn Thạc sĩ Giải pháp nhằm hoàn thiện công tác marketing tại Công Ty TNH...Luận văn Thạc sĩ Giải pháp nhằm hoàn thiện công tác marketing tại Công Ty TNH...
Luận văn Thạc sĩ Giải pháp nhằm hoàn thiện công tác marketing tại Công Ty TNH...
 
13.02.2015 Báo cáo cập nhật cổ phiếu Công ty Cổ phần Thiết bị Y tế Việt Nhật ...
13.02.2015 Báo cáo cập nhật cổ phiếu Công ty Cổ phần Thiết bị Y tế Việt Nhật ...13.02.2015 Báo cáo cập nhật cổ phiếu Công ty Cổ phần Thiết bị Y tế Việt Nhật ...
13.02.2015 Báo cáo cập nhật cổ phiếu Công ty Cổ phần Thiết bị Y tế Việt Nhật ...
 
Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...
Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...
Các yếu tố tác động đến sự hài lòng của sinh viên khi học tập, rèn luyện tại ...
 
Đề tài: Quản trị vốn lưu động của Công ty Bảo vệ thực vật, HAY
Đề tài: Quản trị vốn lưu động của Công ty Bảo vệ thực vật, HAYĐề tài: Quản trị vốn lưu động của Công ty Bảo vệ thực vật, HAY
Đề tài: Quản trị vốn lưu động của Công ty Bảo vệ thực vật, HAY
 
Luận văn: Nghiên cứu hệ thống trạm phát trên tàu 700Teu, HAY
Luận văn: Nghiên cứu hệ thống trạm phát trên tàu 700Teu, HAYLuận văn: Nghiên cứu hệ thống trạm phát trên tàu 700Teu, HAY
Luận văn: Nghiên cứu hệ thống trạm phát trên tàu 700Teu, HAY
 
Câu hỏi quản trị nguồn nhân lực
Câu hỏi quản trị nguồn nhân lựcCâu hỏi quản trị nguồn nhân lực
Câu hỏi quản trị nguồn nhân lực
 
Bản mô tả công việc(nhom4 ql14 18)
Bản mô tả công việc(nhom4 ql14 18)Bản mô tả công việc(nhom4 ql14 18)
Bản mô tả công việc(nhom4 ql14 18)
 
Khóa luận: Hoàn thiện công tác đào tạo nguồn nhân lực tại Công ty, 9 ĐIỂM
Khóa luận: Hoàn thiện công tác đào tạo nguồn nhân lực tại Công ty, 9 ĐIỂMKhóa luận: Hoàn thiện công tác đào tạo nguồn nhân lực tại Công ty, 9 ĐIỂM
Khóa luận: Hoàn thiện công tác đào tạo nguồn nhân lực tại Công ty, 9 ĐIỂM
 
Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ...
 Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ... Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ...
Phát triển kỹ năng mềm cho sinh viên khối ngành kinh tế các trường cao đẳng ...
 
đồ áN môn chi tiết máy thiết kế trạm dẫn động xích tải
đồ áN môn chi tiết máy thiết kế trạm dẫn động xích tảiđồ áN môn chi tiết máy thiết kế trạm dẫn động xích tải
đồ áN môn chi tiết máy thiết kế trạm dẫn động xích tải
 
Avr nang cao
Avr nang caoAvr nang cao
Avr nang cao
 
Tạo động lực cho người lao động tại công ty giống cây trồng
Tạo động lực cho người lao động tại công ty giống cây trồngTạo động lực cho người lao động tại công ty giống cây trồng
Tạo động lực cho người lao động tại công ty giống cây trồng
 
Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...
Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...
Đề tài: Thực trạng và giải pháp nâng cao năng lực cạnh tranh công ty Đông Thi...
 

Viewers also liked

Stata Cheat Sheets (all)
Stata Cheat Sheets (all)Stata Cheat Sheets (all)
Stata Cheat Sheets (all)Laura Hughes
 
Stata cheat sheet: data processing
Stata cheat sheet: data processingStata cheat sheet: data processing
Stata cheat sheet: data processingTim Essam
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat SheetLaura Hughes
 
Stata cheat sheet: Data visualization
Stata cheat sheet: Data visualizationStata cheat sheet: Data visualization
Stata cheat sheet: Data visualizationLaura Hughes
 
Cheat sheet windows complete (xp, 7, 8)
Cheat sheet windows complete (xp, 7, 8)Cheat sheet windows complete (xp, 7, 8)
Cheat sheet windows complete (xp, 7, 8)Hastho Oke Sekali Jaya
 
Stata cheatsheet transformation
Stata cheatsheet transformationStata cheatsheet transformation
Stata cheatsheet transformationLaura Hughes
 
802.11 Protocol Map
802.11 Protocol Map802.11 Protocol Map
802.11 Protocol MapChris x-MS
 
STATA - Summary Statistics
STATA - Summary StatisticsSTATA - Summary Statistics
STATA - Summary Statisticsstata_org_uk
 
The top 10 windows logs event id's used v1.0
The top 10 windows logs event id's used v1.0The top 10 windows logs event id's used v1.0
The top 10 windows logs event id's used v1.0Michael Gough
 
STATA - Probit Analysis
STATA - Probit AnalysisSTATA - Probit Analysis
STATA - Probit Analysisstata_org_uk
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksSlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShareSlideShare
 

Viewers also liked (14)

Stata Cheat Sheets (all)
Stata Cheat Sheets (all)Stata Cheat Sheets (all)
Stata Cheat Sheets (all)
 
Stata cheat sheet: data processing
Stata cheat sheet: data processingStata cheat sheet: data processing
Stata cheat sheet: data processing
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat Sheet
 
Stata cheat sheet: Data visualization
Stata cheat sheet: Data visualizationStata cheat sheet: Data visualization
Stata cheat sheet: Data visualization
 
Cheat sheet windows complete (xp, 7, 8)
Cheat sheet windows complete (xp, 7, 8)Cheat sheet windows complete (xp, 7, 8)
Cheat sheet windows complete (xp, 7, 8)
 
Stata cheatsheet transformation
Stata cheatsheet transformationStata cheatsheet transformation
Stata cheatsheet transformation
 
Ipv6 cheat sheet
Ipv6 cheat sheetIpv6 cheat sheet
Ipv6 cheat sheet
 
802.11 Protocol Map
802.11 Protocol Map802.11 Protocol Map
802.11 Protocol Map
 
STATA - Summary Statistics
STATA - Summary StatisticsSTATA - Summary Statistics
STATA - Summary Statistics
 
The top 10 windows logs event id's used v1.0
The top 10 windows logs event id's used v1.0The top 10 windows logs event id's used v1.0
The top 10 windows logs event id's used v1.0
 
Router commands
Router commandsRouter commands
Router commands
 
STATA - Probit Analysis
STATA - Probit AnalysisSTATA - Probit Analysis
STATA - Probit Analysis
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 

Similar to Stata cheat sheet: data visualization

Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using rTahera Shaikh
 
DrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & EffectsDrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & EffectsShawn Villaron
 
Lecture 02 visualization and programming
Lecture 02   visualization and programmingLecture 02   visualization and programming
Lecture 02 visualization and programmingSmee Kaem Chann
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in RIlya Zhbannikov
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Chia-Chi Chang
 
ggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphicsggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality GraphicsClaus Wilke
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language CHANDAN KUMAR
 
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Aysylu Greenberg
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tddMarcos Iglesias
 

Similar to Stata cheat sheet: data visualization (20)

R training5
R training5R training5
R training5
 
RBootcamp Day 4
RBootcamp Day 4RBootcamp Day 4
RBootcamp Day 4
 
R graphics
R graphicsR graphics
R graphics
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
 
DrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & EffectsDrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & Effects
 
data-visualization.pdf
data-visualization.pdfdata-visualization.pdf
data-visualization.pdf
 
Lecture 02 visualization and programming
Lecture 02   visualization and programmingLecture 02   visualization and programming
Lecture 02 visualization and programming
 
Ggplot
GgplotGgplot
Ggplot
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
 
Clojure
ClojureClojure
Clojure
 
Lec2
Lec2Lec2
Lec2
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)
 
ggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphicsggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphics
 
Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1
 
MATLAB PLOT.pdf
MATLAB PLOT.pdfMATLAB PLOT.pdf
MATLAB PLOT.pdf
 
ML-CheatSheet (1).pdf
ML-CheatSheet (1).pdfML-CheatSheet (1).pdf
ML-CheatSheet (1).pdf
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
 
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tdd
 

Recently uploaded

Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/managementakshesh doshi
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computationsit20ad004
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 

Recently uploaded (20)

Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/management
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computation
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 

Stata cheat sheet: data visualization

  • 1. graph <plot type> y1 y2 … yn x [in] [if], <plot options> by(var) xline(xint) yline(yint) text(y x "annotation")BASIC PLOT SYNTAX: plot sizecustom appearance save variables: y first plot-specific options facet annotations titles axes title("title") subtitle("subtitle") xtitle("x-axis title") ytitle("y axis title") xscale(range(low high) log reverse off noline) yscale(<options>) <marker, line, text, axis, legend, background options> scheme(s1mono) play(customTheme) xsize(5) ysize(4) saving("myPlot.gph", replace) CONTINUOUS DISCRETE (asis) • (percent) • (count) • over(<variable>, <options: gap(*#) • relabel • descending • reverse>) • cw •missing • nofill • allcategories • percentages • stack • bargap(#) • intensity(*#) • yalternate • xalternate graph hbar draws horizontal bar chartsbar plot graph bar (count), over(foreign, gap(*0.5)) intensity(*0.5) bin(#) • width(#) • density • fraction • frequency • percent • addlabels addlabopts(<options>) • normal • normopts(<options>) • kdensity kdenopts(<options>) histogram histogram mpg, width(5) freq kdensity kdenopts(bwidth(5)) main plot-specific options; see help for complete set bwidth • kernel(<options> normal • normopts(<line options>) smoothed histogram kdensity mpg, bwidth(3) (asis) • (percent) • (count) • (stat: mean median sum min max ...) over(<variable>, <options: gap(*#) • relabel • descending • reverse sort(<variable>)>) • cw • missing • nofill • allcategories • percentages linegap(#) • marker(#, <options>) • linetype(dot | line | rectangle) dots(<options>) • lines(<options>) • rectangles(<options>) • rwidth dot plot graph dot (mean) length headroom, over(foreign) m(1, ms(S)) ssc install vioplot over(<variable>, <options: total • missing>)>) • nofill • vertical • horizontal • obs • kernel(<options>) • bwidth(#) • barwidth(#) • dscale(#) • ygap(#) • ogap(#) • density(<options>) bar(<options>) • median(<options>) • obsopts(<options>) violin plot vioplot price, over(foreign) over(<variable>, <options: total • gap(*#) • relabel • descending • reverse sort(<variable>)>) • missing • allcategories • intensity(*#) • boxgap(#) medtype(line | line | marker) • medline(<options>) • medmarker(<options>) graph box draws vertical boxplotsbox plot graph hbox mpg, over(rep78, descending) by(foreign) missing graph hbar ... bar plot graph bar (median) price, over(foreign) (asis) • (percent) • (count) • (stat: mean median sum min max ...) over(<variable>, <options: gap(*#) • relabel • descending • reverse sort(<variable>)>) • cw • missing • nofill • allcategories • percentages stack • bargap(#) • intensity(*#) • yalternate • xalternate graph hbar ...grouped bar plot graph bar (percent), over(rep78) over(foreign) (asis) • (percent) • (count) • over(<variable>, <options: gap(*#) • relabel • descending • reverse>) • cw •missing • nofill • allcategories • percentages • stack • bargap(#) • intensity(*#) • yalternate • xalternatea b c sort • cmissing(yes | no) • vertical, • horizontal base(#) line plot with area shading twoway area mpg price, sort(price) 17 2 10 23 20 jitter(#) • jitterseed(#) • sort • cmissing(yes | no) connect(<options>) • [aweight(<variable>)] scatter plot with labelled values twoway scatter mpg weight, mlabel(mpg) jitter(#) • jitterseed(#) • sort connect(<options>) • cmissing(yes | no) scatter plot with connected lines and symbols see also line twoway connected mpg price, sort(price) (sysuse nlswide1) twoway pcspike wage68 ttl_exp68 wage88 ttl_exp88 vertical, • horizontal Parallel coordinates plot (sysuse nlswide1) twoway pccapsym wage68 ttl_exp68 wage88 ttl_exp88 vertical • horizontal • headlabel Slope/bump plot SUMMARY PLOTS twoway mband mpg weight || scatter mpg weight bands(#) plot median of the y values ssc install binscatter plot a single value (mean or median) for each x value medians • nquantiles(#) • discrete • controls(<variables>) • linetype(lfit | qfit | connect | none) • aweight[<variable>] binscatter weight mpg, line(none) THREE VARIABLES mat(<variable) • split(<options>) • color(<color>) • freq ssc install plotmatrix regress price mpg trunk weight length turn, nocons matrix regmat = e(V) plotmatrix, mat(regmat) color(green) heatmap TWO+ CONTINUOUS VARIABLES bwidth(#) • mean • noweight • logit • adjust calculate and plot lowess smoothing twoway lowess mpg weight || scatter mpg weight FITTING RESULTS level(#) • stdp • stdf • nofit • fitplot(<plottype>) • ciplot(<plottype>) • range(# #) • n(#) • atobs • estopts(<options>) • predopts(<options>) calculate and plot quadriatic fit to data with confidence intervals twoway qfitci mpg weight, alwidth(none) || scatter mpg weight level(#) • stdp • stdf • nofit • fitplot(<plottype>) • ciplot(<plottype>) • range(# #) • n(#) • atobs • estopts(<options>) • predopts(<options>) calculate and plot linear fit to data with confidence intervals twoway lfitci mpg weight || scatter mpg weight REGRESSION RESULTS horizontal • noci regress mpg weight length turn margins, eyex(weight) at(weight = (1800(200)4800)) marginsplot, noci Plot marginal effects of regression ssc install coefplot baselevels • b(<options>) • at(<options>) • noci • levels(#) keep(<variables>) • drop(<variables>) • rename(<list>) horizontal • vertical • generate(<variable>) Plot regression coefficients regress price mpg headroom trunk length turn coefplot, drop(_cons) xline(0) vertical, • horizontal • base(#) • barwidth(#) bar plot twoway bar price rep78 vertical, • horizontal • base(#) dropped line plot twoway dropline mpg price in 1/5 twoway rarea length headroom price, sort vertical • horizontal • sort cmissing(yes | no) range plot (y1 ÷ y2 ) with area shading vertical • horizontal • barwidth(#) • mwidth msize(<marker size>) range plot (y1 ÷ y2 ) with bars twoway rbar length headroom price jitter(#) • jitterseed(#) • sort • cmissing(yes | no) connect(<options>) • [aweight(<variable>)] scatter plot twoway scatter mpg weight, jitter(7) half • jitter(#) • jitterseed(#) diagonal • [aweights(<variable>)] scatter plot of each combination of variables graph matrix mpg price weight, half y3 y2 y1 dot plot twoway dot mpg rep78 vertical, • horizontal • base(#) • ndots(#) dcolor(<color>) • dfcolor(<color>) • dlcolor(<color>) dsize(<markersize>) • dsymbol(<marker type>) dlwidth(<strokesize>) • dotextend(yes | no) ONE VARIABLE sysuse auto, clear DISCRETE X, CONTINUOUS Y twoway contour mpg price weight, level(20) crule(intensity) ccuts(#s) • levels(#) • minmax • crule(hue | chue| intensity) • scolor(<color>) • ecolor (<color>) • ccolors(<colorlist>) • heatmap interp(thinplatespline | shepard | none) 3D contour plot vertical • horizontal range plot (y1 ÷ y2 ) with capped lines twoway rcapsym length headroom price see also rcap Laura Hughes (lhughes@usaid.gov) • Tim Essam (tessam@usaid.gov) inspired by RStudio’s awesome Cheat Sheets (rstudio.com/resources/cheatsheets) geocenter.github.io/StataTraining updated January 2016 Disclaimer: we are not affiliated with Stata. But we like it. CC BY NC Data Visualization with Stata 14.1 Cheat Sheet For more info see Stata’s reference manual (stata.com) Plot Placement SUPERIMPOSE graph twoway scatter mpg price in 27/74 || scatter mpg price /* */ if mpg < 15 & price > 12000 in 27/74, mlabel(make) m(i) combine twoway plots using || scatter y3 y2 y1 x, marker(i o i) mlabel(var3 var2 var1) plot several y values for a single x value graph combine plot1.gph plot2.gph... combine 2+ saved graphs into a single plot JUXTAPOSE (FACET) twoway scatter mpg price, by(foreign, norescale) total • missing • colfirst • rows(#) • cols(#) • holes(<numlist>) compact • [no]edgelabel • [no]rescale • [no]yrescal • [no]xrescale [no]iyaxes • [no]ixaxes • [no]iytick • [no]ixtick [no]iylabel [no]ixlabel • [no]iytitle • [no]ixtitle • imargin(<options>)