Skip to content

Commit abc8cbd

Browse files
committed
v1.1
1 parent 0183f24 commit abc8cbd

File tree

5 files changed

+82
-51
lines changed

5 files changed

+82
-51
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
![StataMin](https://img.shields.io/badge/stata-2015-blue) ![issues](https://img.shields.io/github/issues/asjadnaqvi/stata-arcplot) ![license](https://img.shields.io/github/license/asjadnaqvi/stata-arcplot) ![Stars](https://img.shields.io/github/stars/asjadnaqvi/stata-arcplot) ![version](https://img.shields.io/github/v/release/asjadnaqvi/stata-arcplot) ![release](https://img.shields.io/github/release-date/asjadnaqvi/stata-arcplot)
33

4-
# arcplot v1.0
4+
# arcplot v1.1
55

6-
This package allows us to draw arc plots in Stata. It is based on the [Arc plot Guide](https://medium.com/the-stata-guide/stata-graphs-arc-plots-eb87015510e6) that I released in October 2021.
6+
This package allows us to draw arc plots in Stata. It is based on the [Arc plot Guide](https://medium.com/the-stata-guide/stata-graphs-arc-plots-eb87015510e6) (October 2021).
77

88

99
## Installation
@@ -16,7 +16,7 @@ SSC (**v1.0**):
1616
ssc install arcplot, replace
1717
```
1818

19-
GitHub (**v1.0**):
19+
GitHub (**v1.1**):
2020

2121
```
2222
net install arcplot, from("https://raw.githubusercontent.com/asjadnaqvi/stata-arcplot/main/installation/") replace
@@ -56,7 +56,9 @@ The syntax for **v1.0** is as follows:
5656
```
5757
arcplot *num var* [if] [in], from}(str var) to(str var)
5858
[ gap(num) arcpoints(num) palette(str) alpha(num) format(str)
59-
lwidth(num) lcolor(str) vallabgap(str) vallabangle(str) vallabsize(num)
59+
lwidth(num) lcolor(str)
60+
labgap(str) labangle(str) labsize(str) labpos(str) labcolor(str)
61+
vallabgap(str) vallabangle(str) vallabsize(str) vallabpos(str) vallabcolor(str)
6062
xsize(num) ysize(num) title(str) subtitle(str) note(str) scheme(str) name(str) ]
6163
```
6264

@@ -104,6 +106,12 @@ Please open an [issue](https://github.com/asjadnaqvi/stata-arcplot/issues) to re
104106
## Versions
105107

106108

109+
**v1.1 (08 Nov 2022)**
110+
- Several bug fixes.
111+
- Better label controls.
112+
- Gtools added for faster reshapes.
113+
114+
107115
**v1.0 (21 Aug 2022)**
108116
- Public release.
109117

installation/arcplot.ado

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
1-
*! arcplot v1.0 22 Jun 2022. beta release
1+
*! arcplot v1.1 (22 Jun 2022)
22
*! Asjad Naqvi
33

4+
* v1.1 08Nov2022. Several bug fixes. Improvements to code. Gtools added.
5+
* v1.0 22Jun2022. First beta release
6+
47

58
**********************************
69
* Step-by-step guide on Medium *
710
**********************************
811

9-
* if you want to go for even more customization, you can read this guide:
10-
* Arc plots (Joy plots) (6 Oct, 2021)
12+
* if you want to go for even more customization, you can read the
13+
* Arc plots (6 Oct, 2021) guide:
1114
* https://medium.com/the-stata-guide/stata-graphs-arc-plots-eb87015510e6
1215

1316

1417
cap program drop arcplot
1518

1619

17-
program arcplot, sortpreserve
20+
program arcplot, // sortpreserve
1821

1922
version 15
2023

21-
syntax varlist(min=1 max=1 numeric) [if] [in], From(varname) To(varname) ///
22-
[ gap(real 0.03) ARCPoints(real 50) palette(string) LColor(string) LWidth(string) alpha(real 50) ] ///
23-
[ format(str) VALLABGap(str) VALLABSize(real 1.2) VALLABAngle(string) VALLAColor(string) LABColor(real 2) LABSize(real 2) ] ///
24-
[ title(passthru) subtitle(passthru) note(passthru) scheme(passthru) name(passthru) xsize(passthru) ysize(passthru) ] ///
25-
[ allopt graphopts(string asis) * ]
24+
syntax varlist(min=1 max=1 numeric) [if] [in], From(varname) To(varname) ///
25+
[ gap(real 0.03) ARCPoints(real 50) palette(string) LColor(string) LWidth(string) alpha(real 50) format(str) ] ///
26+
[ VALLABGap(str) VALLABSize(string) VALLABAngle(string) VALLABColor(string) ] ///
27+
[ LABGap(str) LABSize(string) LABAngle(string) LABColor(string) LABPos(string) ] ///
28+
[ title(passthru) subtitle(passthru) note(passthru) scheme(passthru) name(passthru) xsize(passthru) ysize(passthru) ]
2629

2730

2831
// check dependencies
2932
capture findfile colorpalette.ado
3033
if _rc != 0 {
31-
display as error "The palettes package is missing. Install the {stata ssc install palettes, replace:palettes} and {stata ssc install colrspace, replace:colrspace} packages."
34+
display as error "The {bf:palettes} package is missing. Click to install: {stata ssc install palettes, replace:palettes} and {stata ssc install colrspace, replace:colrspace}."
3235
exit
3336
}
3437

38+
capture findfile gtools.ado
39+
if _rc != 0 {
40+
display as error "The {bf:gtools} package is missing. Click to install: {stata ssc install gtools, replace:gtools}."
41+
exit
42+
}
3543

3644
capture findfile labmask.ado
3745
if _rc != 0 {
38-
display as error "The {it:labmask} package is missing. Click {stata ssc install labutil, replace} to install."
39-
exit
46+
qui install labutil, replace
4047
}
4148

4249
marksample touse, strok
4350

4451
preserve
45-
4652
qui {
4753

4854
keep if `touse'
@@ -56,17 +62,17 @@ qui {
5662

5763
gen id = _n
5864

59-
reshape long lab, i(id) j(layer)
65+
greshape long lab, i(id) j(layer)
6066

6167
encode lab, gen(lab2)
6268

63-
sort lab layer value
69+
sort lab layer `varlist'
6470
bysort lab: gen order = _n
6571

6672
egen tag = tag(lab)
6773

6874
expand 2 if tag==1, gen(tag2)
69-
replace value = 0 if tag2==1 // duplicate entries are labeled as zero
75+
replace `varlist' = 0 if tag2==1 // duplicate entries are labeled as zero
7076
replace order = 0 if tag2==1
7177
replace id = 0 if tag2==1
7278

@@ -75,9 +81,9 @@ qui {
7581

7682
// generate cumulative values
7783
sort lab layer order
78-
bysort lab: gen double valsum = sum(value)
84+
bysort lab: gen double valsum = sum(`varlist')
7985

80-
gen double valsumtot = sum(value)
86+
gen double valsumtot = sum(`varlist')
8187
sort lab layer order
8288

8389
// add gaps between arcs
@@ -142,7 +148,7 @@ qui {
142148
// start future block. these are used much later in the last step after reshape
143149
gen double from`x' = r(mean) // from node
144150

145-
summ value if id==`x' & layer==1, meanonly
151+
summ `varlist' if id==`x' & layer==1, meanonly
146152
gen double fval`x' = r(mean) // from value
147153

148154
summ order if id==`x' & layer==1, meanonly
@@ -223,20 +229,20 @@ qui {
223229

224230
sort lab layer order
225231

226-
keep _y1 _x1 _y2 _x2 ymid xmid arc* from* layer value lab2 fval* fmid*
232+
keep _y1 _x1 _y2 _x2 ymid xmid arc* from* layer `varlist' lab2 fval* fmid*
227233

228234
gen id = _n // dummy for reshape
229235

230236

231-
reshape long arcx_in arcy_in arcx_out arcy_out from fval fmid, i(id _x1 _y1 _x2 _y2 xmid ymid layer value lab2) j(num)
237+
greshape long arcx_in arcy_in arcx_out arcy_out from fval fmid, i(id _x1 _y1 _x2 _y2 xmid ymid layer `varlist' lab2) j(num)
232238

233239
ren arcx_in arcx1
234240
ren arcy_in arcy1
235241

236242
ren arcx_out arcx2
237243
ren arcy_out arcy2
238244

239-
reshape long arcx arcy, i(id _x1 _y1 _x2 _y2 num lab2 layer value) j(level)
245+
greshape long arcx arcy, i(id _x1 _y1 _x2 _y2 num lab2 layer `varlist') j(level)
240246

241247
// control variables
242248
egen tag = tag(num)
@@ -271,10 +277,17 @@ qui {
271277
if "`palette'" == "" local palette CET C1
272278
if "`lcolor'" == "" local lcolor black
273279
if "`lwidth'" == "" local lwidth none
274-
if "`vallabangle'" == "" local vallabangle 90
280+
275281
if "`labcolor'" == "" local labcolor black
282+
if "`labangle'" == "" local labangle 0
283+
if "`labgap'" == "" local labgap 0.5
284+
if "`labpos'" == "" local labpos 6
285+
if "`labsize'" == "" local labsize 2
286+
287+
if "`vallabangle'" == "" local vallabangle 90
276288
if "`vallabcolor'" == "" local vallabcolor black
277289
if "`vallabgap'" == "" local vallabgap 2
290+
if "`vallabsize'" == "" local vallabsize 1.2
278291

279292
if "`format'" == "" local format %9.0fc
280293

@@ -292,8 +305,6 @@ qui {
292305
local spikes `spikes' (pcspike _y1 _x1 _y2 _x2 if num==1 & lab==`x', lc( "`r(p`x')'") lwidth(1.5)) ||
293306

294307
}
295-
296-
297308

298309
local arcs
299310

@@ -313,14 +324,13 @@ qui {
313324
twoway ///
314325
`arcs' ///
315326
`spikes' ///
316-
(scatter ymid xmid if num==1 & tag2==1, msize(vsmall) mcolor(none) mlabsize(`labsize') mlab(lab2) mlabpos(6) ) ///
317-
(scatter _y fmid, mcolor(none) mlabsize(`vallabsize') mlab(fval2) mlabpos(12) mlabangle(`vallabangle') mlabgap(`vallabgap') ) ///
327+
(scatter ymid xmid if num==1 & tag2==1, mcolor(none) mlabsize(`labsize') mlab(lab2) mlabpos(`labpos') mlabangle(`labangle') mlabgap(`labgap') ) ///
328+
(scatter _y fmid , mcolor(none) mlabsize(`vallabsize') mlab(fval2) mlabpos(12) mlabangle(`vallabangle') mlabgap(`vallabgap') mlabcolor(`vallabcolor') ) ///
318329
, legend(off) ///
319330
ylabel(0 0.6, nogrid) xlabel(0 1, nogrid) aspect(0.6) ///
320331
xscale(off) yscale(off) `scheme' `name' `title' `subtitle' `note' `xsize' `ysize'
321332

322333
}
323-
324334
restore
325335

326336
end

installation/arcplot.pkg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
v 1.0
1+
v 1.1
22
d {bf:ARCPLOT}: A Stata package for arc plots.
33
d See {bf:help arcplot} after installation.
44
d
@@ -9,9 +9,9 @@ d KW: graphs
99
d KW: arc plot
1010
d
1111
d
12-
d Distribution-Date: 20220826
12+
d Distribution-Date: 20221108
1313
d
14-
d This version: 26 Aug 2022
14+
d This version: 08 Nov 2022
1515
d First version: 21 Aug 2022
1616
d License: MIT
1717
d

installation/arcplot.sthlp

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{smcl}
2-
{* 26August2022}{...}
2+
{* 08November2022}{...}
33
{hi:help arcplot}{...}
4-
{right:{browse "https://github.com/asjadnaqvi/stata-arcplot":arcplot v1.0 (GitHub)}}
4+
{right:{browse "https://github.com/asjadnaqvi/stata-arcplot":arcplot v1.1 (GitHub)}}
55

66
{hline}
77

@@ -15,8 +15,10 @@ The command is based on the following guide on Medium: {browse "https://medium.c
1515

1616
{cmd:arcplot} {it:variable} {ifin}, {cmdab:f:rom}({it:str var}) {cmdab:t:o}({it:str var})
1717
{cmd:[} {cmd:gap}({it:num}) {cmdab:arcp:oints}({it:num}) {cmd:palette}({it:str}) {cmd:alpha}({it:num}) {cmd:format}({it:str})
18-
{cmdab:lw:idth}({it:num}) {cmdab:lc:olor}({it:str}) {cmdab:vallabg:ap}({it:str}) {cmdab:vallaba:ngle}({it:str}) {cmdab:vallabs:ize}({it:num}) {cmdab:vallabc:olor}({it:str})
19-
{cmd:xsize}({it:num}) {cmd:ysize}({it:num}) {cmd:title}({it:str}) {cmd:subtitle}({it:str}) {cmd:note}({it:str}) {cmd:scheme}({it:str}) {cmd:name}({it:str}) {cmd:]}
18+
{cmdab:lc:olor}({it:str}) {cmdab:lw:idth}({it:num})
19+
{cmdab:labg:ap}({it:str}) {cmdab:laba:ngle}({it:str}) {cmdab:labs:ize}({it:num}) {cmdab:labc:olor}({it:str})
20+
{cmdab:vallabg:ap}({it:str}) {cmdab:vallaba:ngle}({it:str}) {cmdab:vallabs:ize}({it:num}) {cmdab:vallabc:olor}({it:str})
21+
{cmd:xsize}({it:num}) {cmd:ysize}({it:num}) {cmd:title}({it:str}) {cmd:subtitle}({it:str}) {cmd:note}({it:str}) {cmd:scheme}({it:str}) {cmd:name}({it:str}) {cmd:]}
2022

2123
{p 4 4 2}
2224

@@ -43,17 +45,24 @@ The command is based on the following guide on Medium: {browse "https://medium.c
4345

4446
{p2coldent : {opt lw:idth(num)}}The outline width of the area fill. Default is {it:none}.{p_end}
4547

46-
{p2coldent : {opt vallabg:ap(str)}}The gap of the value labels from the horizontal bars. The default value is {it:2}.{p_end}
4748

48-
{p2coldent : {opt vallaba:ngle(str)}}The angle of the value labels. The default value is {it:90} for 90 degrees.{p_end}
49+
{p2coldent : {opt labs:ize(str)}}The size of the category labels. The default value is {it:2}.{p_end}
50+
51+
{p2coldent : {opt labc:olor(str)}}The color of the category labels. The default value is {it:black}.{p_end}
52+
53+
{p2coldent : {opt laba:ngle(str)}}The angle of the category labels. The default value is {it:0} for horizontal.{p_end}
4954

50-
{p2coldent : {opt vallabs:ize(num)}}The size of the value labels. The default value is {it:1.2}.{p_end}
55+
{p2coldent : {opt labg:ap(str)}}The gap of the category labels. The default value is {it:0.5}.{p_end}
56+
57+
58+
{p2coldent : {opt vallabs:ize(str)}}The size of the value labels. The default value is {it:1.2}.{p_end}
5159

5260
{p2coldent : {opt vallabc:olor(str)}}The color of the value labels. The default value is {it:black}.{p_end}
5361

54-
{p2coldent : {opt labs:ize(num)}}The size of the category labels. The default value is {it:2}.{p_end}
62+
{p2coldent : {opt vallaba:ngle(str)}}The angle of the value labels. The default value is {it:90} for 90 degrees.{p_end}
63+
64+
{p2coldent : {opt vallabg:ap(str)}}The gap of the value labels from the horizontal bars. The default value is {it:2}.{p_end}
5565

56-
{p2coldent : {opt labc:olor(num)}}The color of the category labels. The default value is {it:black}.{p_end}
5766

5867
{p2coldent : {opt title}, {opt subtitle}, {opt note}}These are standard twoway graph options.{p_end}
5968

@@ -69,12 +78,16 @@ The command is based on the following guide on Medium: {browse "https://medium.c
6978

7079
{title:Dependencies}
7180

72-
The {browse "http://repec.sowi.unibe.ch/stata/palettes/index.html":palette} package (Jann 2018) is required for {cmd:arcplot}:
81+
{cmd:arcplot} requires {browse "http://repec.sowi.unibe.ch/stata/palettes/index.html":palettes} package (Jann 2018):
7382

7483
{stata ssc install palettes, replace}
7584
{stata ssc install colrspace, replace}
7685

77-
Even if you have these installed, it is highly recommended to update the dependencies:
86+
and {browse "https://gtools.readthedocs.io/en/latest/":gtools} package:
87+
88+
{stata ssc install gtools, replace}
89+
90+
Even if you have these installed, it is highly recommended to check for their updates:
7891
{stata ado update, update}
7992

8093
{title:Examples}
@@ -87,14 +100,14 @@ Check {browse "https://github.com/asjadnaqvi/arcplot":GitHub} for examples.
87100

88101
{title:Version history}
89102

90-
103+
- {bf:1.1} : Various bug fixes. Improvements to label controls. Gtools added for faster reshaping.
91104
- {bf:1.0} : First version.
92105

93106

94107
{title:Package details}
95108

96-
Version : {bf:arcplot} v1.0
97-
This release : 26 Aug 2022
109+
Version : {bf:arcplot} v1.1
110+
This release : 08 Nov 2022
98111
First release: 21 Aug 2021
99112
Repository : {browse "https://github.com/asjadnaqvi/arcplot":GitHub}
100113
Keywords : Stata, graph, arc plot
@@ -117,4 +130,4 @@ Please submit bugs, errors, feature requests on {browse "https://github.com/asja
117130

118131
{p 4 8 2}Jann, B. (2018). {browse "https://www.stata-journal.com/article.html?article=gr0075":Color palettes for Stata graphics}. The Stata Journal 18(4): 765-785.
119132

120-
133+
{p 4 8 2}Caceres, M. (2022). {browse "https://gtools.readthedocs.io/en/latest/":Gtools website}.

installation/stata.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
v 1.0
1+
v 1.1
22
d 'ARCPLOT': A Stata package for creating arc plots
33
d Asjad Naqvi,
44

0 commit comments

Comments
 (0)