Skip to content

Commit 02c5b2a

Browse files
committed
v1.52
1 parent d2a08b4 commit 02c5b2a

File tree

7 files changed

+76
-55
lines changed

7 files changed

+76
-55
lines changed

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ authors:
33
- family-names: "Naqvi"
44
given-names: "Asjad"
55
title: "Stata package ``graphfunctions''"
6-
version: 1.5
7-
date-released: 2024-11-05
6+
version: 1.52
7+
date-released: 2025-02-18
88
url: "https://github.com/asjadnaqvi/stata-graphfunctions"

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) 2024 Asjad Naqvi
3+
Copyright (c) 2025 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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88

99

10-
# graphfunctions v1.51
11-
*(28 Nov 2024)*
10+
# graphfunctions v1.52
11+
*(18 Feb 2025)*
1212

1313
A suite of graph functions for Stata. The program is designed to be called by other programs, but it can be used as a standalone as well. The page will provide some minimum examples, but for the full scope, see the relevant help files.
1414

@@ -18,7 +18,7 @@ Currently, this package contains:
1818
|Program|Version|Updated|Description|
1919
|----| ---- | ---- | ----- |
2020
| [labsplit](#labsplit) | 1.1 | 08 Oct 2024 | Text wrapping |
21-
| [catspline](#catspline) | 1.1 | 28 Nov 2024 | Catmull-Rom splines |
21+
| [catspline](#catspline) | 1.2 | 18 Feb 2024 | Catmull-Rom splines |
2222
| [arc](#arc) | 1.2 | 20 Nov 2024 | Draw arcs between two points |
2323
| [shapes](#shapes) | 1.3 | 05 Nov 2024 | Contains `shapes circle`, `shapes pie`, `shapes square`, `shapes rotate`, `shapes area` |
2424

@@ -35,7 +35,7 @@ SSC (**v1.51**):
3535
ssc install graphfunctions, replace
3636
```
3737

38-
GitHub (**v1.51**):
38+
GitHub (**v1.52**):
3939

4040
```stata
4141
net install graphfunctions, from("https://raw.githubusercontent.com/asjadnaqvi/stata-graphfunctions/main/installation/") replace
@@ -104,7 +104,7 @@ twoway (scatter y x, mlabel(newlab3) mlabsize(3)), title("Word wrap")
104104
<img src="/figures/labsplit2.png" width="50%"><img src="/figures/labsplit3.png" width="50%">
105105

106106
### catspline
107-
*(v1.0: 04 Oct 2024)*
107+
*(v1.2: 18 Feb 2025)*
108108

109109

110110
The program allows users to generate splines based on the [Catmull-Rom algorithm](https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline).
@@ -550,6 +550,11 @@ Please open an [issue](https://github.com/asjadnaqvi/stata-graphfunctions/issues
550550

551551
## Change log
552552

553+
**v1.52 (18 Feb 2025)**
554+
- `catspline` now generate the stated number of points.
555+
- `catspline` now respects `if/in` conditions.
556+
- Minor corrections and bug fixes.
557+
553558
**v1.51 (28 Nov 2024)**
554559
- Fixed `catspline` to correct generate splines. Added options to replace variables. Change in routine to make it more efficient in computations.
555560
- Added `replace`, `append` to `arc`. Various bug fixes.

installation/catspline.ado

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
*! catspline v1.1 (28 Nov 2024)
1+
*! catspline v1.2 (18 Feb 2025): Fixed marksample bug.
22
*! Asjad Naqvi (asjadnaqvi@gmail.com)
33

4+
* v1.2 (18 Feb 2025): Fixed marksample bug.
45
* v1.1 (28 Nov 2024): Fix an issue with observations stacking. Fixed a minor bug in sort. Added a sort(), replace variable.
56
* v1.0 (04 Oct 2024): first release.
67

78

89
/*
9-
to do: add option "replace", add option `sort()'.
10-
10+
to do: add option `sort()'.
1111
1212
*/
1313

1414

1515
cap program drop catspline
1616

17-
program catspline, // sortpreserve
17+
program catspline, sortpreserve
1818

1919
version 11
2020

2121
syntax varlist(numeric min=2 max=2) [if] [in], [ rho(numlist max=1 >=0 <=1) n(real 40) close noid genx(string) geny(string) genid(string) genorder(string) sort(varlist max=1) replace ]
2222

23-
tokenize `varlist'
24-
local vary `1'
25-
local varx `2'
2623

2724
// prepare the variables
2825
local xvar _x
@@ -46,27 +43,36 @@ version 11
4643

4744
cap confirm var _id
4845
if !_rc {
49-
display as error "Variable {it:_id} already exists."
46+
display as error "Variable {it:_id} already exists. Option {it:replace} can be used to overwrite."
5047
exit
5148
}
5249

50+
51+
marksample touse, strok
52+
5353
quietly {
5454
preserve
5555

56+
keep if `touse'
57+
58+
keep `varlist' `sort'
59+
60+
tokenize `varlist'
61+
local vary `1'
62+
local varx `2'
5663

57-
5864

59-
keep `varlist' `sort'
65+
6066
drop if missing(`varx')
6167
drop if missing(`vary')
62-
68+
69+
6370
if "`sort'" != "" sort `sort'
6471

6572
gen pts = _n
6673
order pts
6774

6875

69-
7076
if "`rho'" == "" local rho 0.5
7177

7278
if `n' < 5 {
@@ -77,8 +83,13 @@ preserve
7783

7884
if _N < `n' set obs `n'
7985

86+
87+
8088
gen id = _n - 1
8189

90+
91+
92+
8293
levelsof pts, local(points)
8394
local last = r(r)
8495

@@ -114,7 +125,10 @@ preserve
114125
gen double `t3' = (((`x3' - `x2')^2 + (`y3' - `y2')^2)^`rho') + `t2'
115126

116127
local diff = abs(`t2' - `t1') / (`n' - 1)
117-
gen double t`x' = `t1' + (`diff' * id)
128+
129+
*local diff = abs(`n') / (`n' - 1)
130+
131+
gen double t`x' = `t1' + (`diff' * id) in 1/`n'
118132

119133

120134
**** calculate the As
@@ -146,23 +160,35 @@ preserve
146160

147161
}
148162

149-
163+
150164
cap drop `varlist' pts id
151165

152-
local obs2 = `n'+ 1
153-
if _N < `obs2' set obs `obs2' // add an empty row
166+
drop if t1==.
167+
168+
169+
170+
set obs `= `n'+ 1' // add an empty row
154171

155172

156173
gen `ordervar' = _n
174+
175+
176+
177+
157178
reshape long `xvar' `yvar' t, i(`ordervar') j(`idvar')
158179

159-
160-
if "`close'" == "" drop if `idvar'==`last' - 1
161-
162-
drop t
163180
order `idvar' `ordervar'
164181
sort `idvar' `ordervar'
165182

183+
184+
if "`close'" == "" {
185+
summ `idvar'
186+
drop if `idvar'==r(max)
187+
}
188+
189+
drop t
190+
191+
166192
tempfile mysplines
167193
save `mysplines', replace
168194

@@ -183,7 +209,7 @@ restore
183209
merge m:1 `idvar' `ordervar' using `mysplines'
184210
drop _merge
185211

186-
212+
*/
187213

188214
}
189215

installation/catspline.sthlp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{smcl}
2-
{* 28Nov2024}{...}
2+
{* 18Feb2025}{...}
33
{hi:help catspline}{...}
44
{right:{browse "https://github.com/asjadnaqvi/stata-graphfunctions":graphfunctions (GitHub)}}
55

@@ -63,8 +63,8 @@ More examples on {browse "https://github.com/asjadnaqvi/stata-graphfunctions":Gi
6363

6464
{title:Package details}
6565

66-
Version : {bf:catspline} v1.1 in {stata help graphfunctions:graphfunctions}
67-
This release : 28 Nov 2024
66+
Version : {bf:catspline} v1.2 in {stata help graphfunctions:graphfunctions}
67+
This release : 18 Feb 2025
6868
First release: 04 Oct 2024
6969
Repository : {browse "https://github.com/asjadnaqvi/stata-graphfunctions":GitHub}
7070
Keywords : Stata, graph, splines, catmull rom function

installation/graphfunctions.pkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
v 1.51
1+
v 1.52
22
d {bf:GRAPHFUNCTIONS}: A collection of functions to extend graph functionality in Stata
33
d
44
d Requires: Stata version 11 or higher.
@@ -10,7 +10,7 @@ d KW: text wrap
1010
d KW: splines
1111
d KW: shapes
1212
d
13-
d Distribution-Date: 20241128
13+
d Distribution-Date: 20250218
1414
d License: MIT
1515
d
1616
d Author: Asjad Naqvi (asjadnaqvi@gmail.com)

installation/graphfunctions.sthlp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{smcl}
2-
{* 28Nov2024}{...}
2+
{* 18Feb2025}{...}
33
{hi:help graphfunctions}{...}
4-
{right:{browse "https://github.com/asjadnaqvi/stata-graphfunctions":graphfunctions v1.51 (GitHub)}}
4+
{right:{browse "https://github.com/asjadnaqvi/stata-graphfunctions":graphfunctions v1.52 (GitHub)}}
55

66

77
{title:GRAPH FUNCTIONS}:
@@ -12,7 +12,7 @@ This package contains the following program(s):
1212
{hline}
1313

1414
{stata help labsplit:labsplit} v1.1 (08 Oct 2024) Various options for wrapping labels.
15-
{stata help catspline:catspline} v1.1 (28 Nov 2024) Generate Catmull-Rom splines.
15+
{stata help catspline:catspline} v1.2 (18 Feb 2025) Generate Catmull-Rom splines.
1616
{stata help arc:arc} v1.2 (20 Nov 2024) Draw an arc between two points.
1717
{stata help shapes:shapes} v1.3 (05 Nov 2024) Draw shapes. Contains several sub programs.
1818

@@ -31,23 +31,14 @@ Please submit bugs, errors, feature requests on {browse "https://github.com/asja
3131

3232
{title:Citation guidelines}
3333

34-
Suggested citation guidlines for this package:
35-
36-
Naqvi, A. (2024). Stata package "graphfunctions" version 1.51. Release date 28 November 2024. https://github.com/asjadnaqvi/stata-graphfunctions.
37-
38-
@software{graphfunctions,
39-
author = {Naqvi, Asjad},
40-
title = {Stata package ``graphfunctions''},
41-
url = {https://github.com/asjadnaqvi/stata-graphfunctions},
42-
version = {1.51},
43-
date = {2024-11-28}
44-
}
34+
See {browse "https://ideas.repec.org/c/boc/bocode/s459379.html"} for the official SSC citation.
35+
Please note that the GitHub version might be newer than the SSC version.
4536

4637

4738
{title:Package details}
4839

49-
Version : {bf:graphfunctions} v1.51
50-
This release : 28 Nov 2024
40+
Version : {bf:graphfunctions} v1.52
41+
This release : 18 Feb 2025
5142
First release: 28 Sep 2024
5243
Repository : {browse "https://github.com/asjadnaqvi/stata-graphfunctions":GitHub}
5344
License : {browse "https://opensource.org/licenses/MIT":MIT}
@@ -57,10 +48,9 @@ E-mail : asjadnaqvi@gmail.com
5748
Twitter/X : {browse "https://x.com/AsjadNaqvi":@AsjadNaqvi}
5849

5950

60-
{title:Other packages}
61-
51+
{title:Other visualization packages}
6252
{psee}
63-
{helpb arcplot}, {helpb alluvial}, {helpb bimap}, {helpb bumparea}, {helpb bumpline}, {helpb circlebar}, {helpb circlepack}, {helpb clipgeo}, {helpb delaunay}, {helpb graphfunctions}, {helpb joyplot},
64-
{helpb marimekko}, {helpb polarspike}, {helpb sankey}, {helpb schemepack}, {helpb spider}, {helpb splinefit}, {helpb streamplot}, {helpb sunburst}, {helpb ternary}, {helpb treecluster}, {helpb treemap}, {helpb trimap}, {helpb waffle}
53+
{helpb arcplot}, {helpb alluvial}, {helpb bimap}, {helpb bumparea}, {helpb bumpline}, {helpb circlebar}, {helpb circlepack}, {helpb clipgeo}, {helpb delaunay}, {helpb graphfunctions}, {helpb geoboundary}, {helpb geoflow}, {helpb joyplot},
54+
{helpb marimekko}, {helpb polarspike}, {helpb sankey}, {helpb schemepack}, {helpb spider}, {helpb splinefit}, {helpb streamplot}, {helpb sunburst}, {helpb ternary}, {helpb tidytuesday}, {helpb treecluster}, {helpb treemap}, {helpb trimap}, {helpb waffle}
6555

66-
or visit {browse "https://github.com/asjadnaqvi":GitHub}.
56+
Visit {browse "https://github.com/asjadnaqvi":GitHub} for further information.

0 commit comments

Comments
 (0)