Skip to content

Commit 1586db9

Browse files
committed
v1.3
1 parent 5eaac3e commit 1586db9

17 files changed

+281
-112
lines changed

CITATION.cff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cff-version: 1.2.0
22
authors:
33
- family-names: "Naqvi"
44
given-names: "Asjad"
5-
title: "Stata package ``bimap''"
6-
version: 1.6
7-
date-released: 2023-03-17
8-
url: "https://github.com/asjadnaqvi/stata-bimap"
5+
title: "Stata package ``arcplot''"
6+
version: 1.3
7+
date-released: 2024-03-31
8+
url: "https://github.com/asjadnaqvi/stata-arcplot"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Asjad Naqvi
3+
Copyright (c) 2024 Asjad Naqvi
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 89 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
---
1111

12-
# arcplot v1.2
12+
# arcplot v1.3
1313
(16 Feb 2023)
1414

1515
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).
@@ -25,19 +25,19 @@ SSC (**v1.2**):
2525
ssc install arcplot, replace
2626
```
2727

28-
GitHub (**v1.2**):
28+
GitHub (**v1.3**):
2929

3030
```
3131
net install arcplot, from("https://raw.githubusercontent.com/asjadnaqvi/stata-arcplot/main/installation/") replace
3232
```
3333

3434

35-
36-
The `palettes` package is required to run this command:
35+
The following packages are required to run this command:
3736

3837
```
3938
ssc install palettes, replace
4039
ssc install colrspace, replace
40+
ssc install gtools, replace
4141
```
4242

4343
Even if you have these packages installed, please check for updates: `ado update, update`.
@@ -60,25 +60,28 @@ graph set window fontface "Arial Narrow"
6060

6161
## Syntax
6262

63-
The syntax for **v1.2** is as follows:
63+
The syntax for the latest version is as follows:
64+
65+
```stata
66+
arcplot var [if] [in], from(var) to(var)
67+
[ gap(num) arcpoints(num) palette(str) alpha(num) format(str) lcolor(str) lwidth(num)
68+
sort(value|name) boxwidth(str) boxintensity(num) offset(num)
69+
labgap(str) labangle(str) labsize(num) labcolor(str) labpos(str)
70+
valgap(str) valangle(str) valsize(num) valcolor(str) valpos(str) valcondition(num)
71+
aspect(num) xsize(num) ysize(num) title(str) subtitle(str) note(str) scheme(str) name(str)
72+
]
6473
65-
```
66-
arcplot *num var* [if] [in], from(str var) to(str var)
67-
[ gap(num) arcpoints(num) palette(str) alpha(num) format(str) lwidth(num) lcolor(str)
68-
labgap(str) labangle(str) labsize(str) labpos(str) labcolor(str)
69-
vallabgap(str) vallabangle(str) vallabsize(str) vallabpos(str) vallabcolor(str)
70-
xsize(num) ysize(num) title(str) subtitle(str) note(str) scheme(str) name(str) ]
7174
```
7275

7376
See the help file `help arcplot` for details.
7477

7578
The most basic use is as follows:
7679

7780
```
78-
arcplot values, from(var1) to(var2)
81+
arcplot var, from(var1) to(var2)
7982
```
8083

81-
where `var1` and `var2` are the string source and destination variables respectively against which the `values` are plotted. Out going values have the same color as the horizontal bar, while the incoming values have the colors of respective bars. This might still be refined but this is in line with standard arcplot packages in other softwares.
84+
where `var1` and `var2` are the string source and destination variables respectively against which the numerical `var` variable is plotted. Out going values have the same color as the horizontal bar, while the incoming values have the colors of respective bars. Incoming boxes have a slightly different shade.
8285

8386

8487

@@ -87,38 +90,106 @@ where `var1` and `var2` are the string source and destination variables respecti
8790
Get the example data from GitHub:
8891

8992
```
90-
use "https://github.com/asjadnaqvi/stata-arcplot/blob/main/data/sankey_example.dta?raw=true", clear
93+
use "https://github.com/asjadnaqvi/stata-arcplot/blob/main/data/trade_2022.dta?raw=true", clear
9194
```
9295

9396
Let's test the `arcplot` command:
9497

9598
```
96-
arcplot value, from(source) to(destination) palette(tableau) alpha(55)
99+
arcplot value, from(ex_region) to(im_region)
97100
```
98101

99-
<img src="/figures/arcplot1_bw.png" width="100%">
102+
<img src="/figures/arcplot1.png" width="100%">
100103

101104

102105
```
103-
arcplot value, f(source) t(destination) alpha(40) format(%9.2fc) gap(0.01) vallabg(3) vallabs(1.5) lc(black) lw(0.03) palette(CET C6)
106+
arcplot value, from(ex_subregion) to(im_subregion)
104107
```
105108

106109
<img src="/figures/arcplot2.png" width="100%">
107110

108111
```
109-
arcplot value, from(source) to(destination) vallabsize(1.3) lw(none) alpha(50)
112+
arcplot value, from(ex_subregion) to(im_subregion) ///
113+
labangle(45) labpos(7)
110114
```
111115

112116
<img src="/figures/arcplot3.png" width="100%">
113117

114118

119+
```
120+
arcplot value, from(ex_subregion) to(im_subregion) ///
121+
gap(1) labsize(1.3) labangle(45) labpos(7) labgap(0.5) offset(1)
122+
```
123+
124+
<img src="/figures/arcplot4.png" width="100%">
125+
126+
```
127+
arcplot value, from(ex_subregion) to(im_subregion) ///
128+
gap(1) labsize(1.3) labangle(45) labpos(7) labgap(0.5) offset(1)
129+
```
130+
131+
<img src="/figures/arcplot5.png" width="100%">
132+
133+
```
134+
arcplot value, from(ex_subregion) to(im_subregion) ///
135+
gap(1) labsize(1.3) labangle(45) labpos(7) labgap(0.5) ///
136+
offset(1) valcolor(black) valcond(100)
137+
```
138+
139+
<img src="/figures/arcplot6.png" width="100%">
140+
141+
142+
Let's drop the minor regions:
143+
144+
```
145+
drop if inlist(ex_subregion, "Melanesia", "Micronesia", "Polynesia")
146+
drop if inlist(im_subregion, "Melanesia", "Micronesia", "Polynesia")
147+
```
148+
149+
150+
151+
```
152+
arcplot value, from(ex_subregion) to(im_subregion) ///
153+
gap(0.5) labsize(1.3) labangle(45) labpos(7) labgap(0.5) ///
154+
offset(1) valcolor(black) valcond(200) palette(CET C6)
155+
```
156+
157+
<img src="/figures/arcplot7.png" width="100%">
158+
159+
```
160+
arcplot value, from(ex_region) to(im_region) ///
161+
gap(2) labsize(2) labangle(45) labpos(7) labgap(0.5) ///
162+
offset(1) valcolor(black) valcond(200) palette(CET C6) ///
163+
lc(black) lw(0.02) boxint(0.6) boxwid(2) alpha(50)
164+
```
165+
166+
<img src="/figures/arcplot8.png" width="100%">
167+
168+
```
169+
arcplot value, from(ex_region) to(im_region) ///
170+
gap(1) labsize(2) labangle(45) labpos(7) labgap(0.5) ///
171+
offset(1) valcolor(black) valcond(200) ///
172+
lc(black) lw(0.02) boxint(0.6) boxwid(2) alpha(50) ///
173+
title("Value of regional trade (USD millions)") note("Source: COMTRADE-BACI", size(1.5))
174+
```
175+
176+
<img src="/figures/arcplot9.png" width="100%">
177+
115178
## Feedback
116179

117180
Please open an [issue](https://github.com/asjadnaqvi/stata-arcplot/issues) to report errors, feature enhancements, and/or other requests.
118181

119182

120183
## Change log
121184

185+
**v1.3 (31 Mar 2024)**
186+
- Options `sort()`, `boxwith()`, `boxintensity()`, `offset()`, `aspect()` added.
187+
- Value labels of arcs now have simplified option names.
188+
- `boxintensity()` allows users to control the color grading of the incoming flows part of the box.
189+
- X-axis `gap()` for gaps between boxes and y-axis `offset()` now take on percentage values.
190+
- Several defaults updates.
191+
- Several fixes to optmize the code and draw faster.
192+
122193
**v1.2 (16 Feb 2023)**
123194
- Massive speed improvements by flattening the code.
124195

data/sankey_example.dta

-4.19 KB
Binary file not shown.

data/trade_2022.dta

30.2 KB
Binary file not shown.

figures/arcplot1.png

281 KB
Loading

figures/arcplot1_bw.png

-407 KB
Binary file not shown.

figures/arcplot2.png

640 KB
Loading

figures/arcplot3.png

762 KB
Loading

figures/arcplot4.png

1.13 MB
Loading

0 commit comments

Comments
 (0)