Skip to content

Commit

Permalink
v1.31
Browse files Browse the repository at this point in the history
  • Loading branch information
asjadnaqvi committed May 11, 2024
1 parent 6dac826 commit 3113b5e
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 33 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ authors:
- family-names: "Naqvi"
given-names: "Asjad"
title: "Stata package ``spider''"
version: 1.3
date-released: 2024-02-16
version: 1.31
date-released: 2024-05-11
url: "https://github.com/asjadnaqvi/stata-spider"
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

---

# spider v1.3
(16 Feb 2024)
# spider v1.31
(11 May 2024)

This package provides the ability to draw spiders Stata. It is based on the [Spider plots](https://medium.com/the-stata-guide/stata-graphs-spider-plots-613808b51f73) guide on Medium

Expand All @@ -24,7 +24,7 @@ The SSC version (**v1.23**):
ssc install spider, replace
```

Or it can be installed from GitHub (**v1.3**):
Or it can be installed from GitHub (**v1.31**):

```
net install spider, from("https://raw.githubusercontent.com/asjadnaqvi/stata-spider/main/installation/") replace
Expand Down Expand Up @@ -62,13 +62,10 @@ The syntax for the latest version is as follows:

```stata
spider var [if] [in], by(var)
[ over(var) alpha(num 0-100) rotate(num) smooth(num 0-1) palette(str)
range(min max) cuts(num) lwidth(str) msymbol(str) rotatelabel
raformat(fmt) ralabsize(str) ralabcolor(str) ralabangle(str)
msize(str) mlwidth(str) displacelab(num) displacespike(num)
ccolor(str) cwidth(str) scolor(str) swidth(str) slabsize(str) slabcolor(str)
nolegend legpositon(num) legpositon(num) legcolumns(num) legsize(num) xsize(num) ysize(num)
title(str) subtitle(str) note(str) scheme(str) name(str) saving(str)
[ over(var) alpha(num 0-100) rotate(num) smooth(num 0-1) palette(str) range(min max) cuts(num) lwidth(str) msymbol(str) rotatelabel
format(fmt) ralabsize(str) ralabcolor(str) ralabangle(str) msize(str) mlwidth(str) displacelab(num) displacespike(num)
ccolor(str) cwidth(str) scolor(str) swidth(str) slabsize(str) slabcolor(str) nolegend legpositon(num) legpositon(num) legcolumns(num) legsize(num)
xsize(num) ysize(num) *
]
```

Expand Down Expand Up @@ -271,6 +268,12 @@ Please open an [issue](https://github.com/asjadnaqvi/stata-spider/issues) to rep

## Change log

**v1.31 (11 May 2024)**
- changed `raformat()` to just `format()` to standardize the use across packages.
- `format()` default improved to show decimals.
- Checks added for `by()` and `over()` to have minimum number of accepted categories.
- Stata default passthru options improved.

**v1.3 (16 Feb 2024)**
- Complete rework of the package to take in the data in the long form. While this might be convinient for users who were using it for wide data, the newer version handle the data and labels better and is faster. The wide option might still be added back in later. Please note that change in the `by()` and `over()` options.
- `rotatelabel` option added.
Expand Down
Binary file modified figures/spider10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider5_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider7_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider7_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider7_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider8_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider8_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider9_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider9_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider9_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider9_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/spider9_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/valentines2024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 24 additions & 10 deletions installation/spider.ado
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*! spider v1.3 (16 Feb 2024)
*! spider v1.31 (11 May 2024)
*! Asjad Naqvi (asjadnaqvi@gmail.com)

* v1.31 (11 May 2024): changed raformat() to format(). Format default improved. by() and over() error checks added. passthru changed to *.
* v1.3 (16 Feb 2024): rewrite to suport long form, add rotate label, better legend controls.
* v1.23 (12 Nov 2023): Added slabcolor(), saving()
* v1.22 (03 Jul 2023): Fixed bug with numerical variables not passing correctly.
Expand All @@ -18,20 +19,18 @@

cap program drop spider


program spider, sortpreserve

version 15

syntax varlist(numeric max=1) [if] [in], by(varname) ///
[ over(varname) alpha(real 10) ROtate(real 30) DISPLACELab(real 15) DISPLACESpike(real 2) palette(string) ] ///
[ RAnge(numlist min=2 max=2) cuts(real 6) smooth(numlist max=1 >=0 <=1) raformat(string) RALABSize(string) ] ///
[ RAnge(numlist min=2 max=2) cuts(real 6) smooth(numlist max=1 >=0 <=1) format(string) RALABSize(string) ] ///
[ LWidth(string) MSYMbol(string) MSize(string) MLWIDth(string) ] /// // spider properties
[ CColor(string) CWidth(string) SColor(string) SWidth(string) SLABSize(string) ] /// // circle = C, spikes = S
[ title(passthru) subtitle(passthru) note(passthru) scheme(passthru) name(passthru) saving(passthru) ] ///
[ NOLEGend LEGPOSition(real 6) LEGCOLumns(real 3) LEGSize(real 2.2) xsize(real 1) ysize(real 1) ] /// // v1.2 updates.
[ RALABColor(string) RALABAngle(string) SLABColor(string) ] /// // v1.2X options
[ ROTATELABel ]
[ NOLEGend LEGPOSition(real 6) LEGCOLumns(real 3) LEGSize(real 2.2) ] /// // v1.2 updates.
[ RALABColor(string) RALABAngle(string) SLABColor(string) ROTATELABel ] /// // v1.2X options
[ xsize(real 1) ysize(real 1) * ]


// check dependencies
Expand All @@ -55,6 +54,13 @@ preserve
keep if `touse'
keep `varlist' `by' `over'

levelsof `by'
if r(r) < 3 {
display as error "by() variable should contain at least three categories."
exit
}


cap confirm numeric var `by'

if _rc!=0 { // if string
Expand All @@ -78,6 +84,14 @@ preserve
local overswitch = 1
}
else {

levelsof `over'

if r(r) < 2 {
display as error "over() variable should contain at least two categories."
exit
}

local overswitch = 0
cap confirm numeric var `over'

Expand Down Expand Up @@ -193,7 +207,7 @@ preserve
///////////////////////


if "`raformat'" == "" local raformat %5.0f
if "`format'" == "" local format %12.1f

local gap2 = (`norm2' - `norm1') / (`cuts' - 1)

Expand All @@ -204,7 +218,7 @@ preserve
local i = 1

forval x = 0(`gap')100 {
replace xlab = string(`norm1' + ((`i' - 1) * `gap2'), "`raformat'") in `i'
replace xlab = string(`norm1' + ((`i' - 1) * `gap2'), "`format'") in `i'
replace xvar = `x' in `i'
replace yvar = 0 in `i'

Expand Down Expand Up @@ -355,7 +369,7 @@ preserve
xscale(off) yscale(off) ///
xlabel(, nogrid) ylabel(, nogrid) ///
`mylegend' ///
`title' `subtitle' `note' `scheme' `name' `saving'
`options'



Expand Down
4 changes: 2 additions & 2 deletions installation/spider.pkg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v 1.3
v 1.31
d {bf:SPIDER}: A Stata package for spider plots.
d See {bf:help spider} after installation.
d
Expand All @@ -11,7 +11,7 @@ d
d
d Distribution-Date: 20240216
d
d This version: 16 Feb 2024
d This version: 11 May 2024
d First version: 13 Oct 2022
d License: MIT
d
Expand Down
14 changes: 7 additions & 7 deletions installation/spider.sthlp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{smcl}
{* 16Feb2024}{...}
{* 11May2024}{...}
{hi:help spider}{...}
{right:{browse "https://github.com/asjadnaqvi/stata-spider":spider v1.3 (GitHub)}}
{right:{browse "https://github.com/asjadnaqvi/stata-spider":spider v1.31 (GitHub)}}

{hline}

Expand All @@ -16,7 +16,7 @@ The command is based on the following guide on Medium: {browse "https://medium.c
{cmd:spider} {it:var} {ifin}, {cmd:by}({it:var})
{cmd:[} {cmd:over}({it:var}) {cmd:alpha}({it:num 0-100}) {cmdab:ro:tate}({it:num}) {cmd:smooth}({it:num 0-1}) {cmd:palette}({it:str})
{cmdab:ra:nge}({it:min max}) {cmd:cuts}({it:num}) {cmdab:lw:idth}({it:str}) {cmdab:msym:bol}({it:str}) {cmdab:rotatelab:el}
{cmd:raformat}({it:fmt}) {cmdab:ralabs:ize}({it:str}) {cmdab:ralabc:olor}({it:str}) {cmdab:ralaba:ngle}({it:str})
{cmd:format}({it:fmt}) {cmdab:ralabs:ize}({it:str}) {cmdab:ralabc:olor}({it:str}) {cmdab:ralaba:ngle}({it:str})
{cmdab:ms:ize}({it:str}) {cmdab:mlw:idth}({it:str}) {cmdab:displacel:ab}({it:num}) {cmdab:displaces:pike}({it:num})
{cmdab:cc:olor}({it:str}) {cmdab:cw:idth}({it:str}) {cmdab:sc:olor}({it:str}) {cmdab:sw:idth}({it:str}) {cmdab:slabs:ize}({it:str}) {cmdab:slabc:olor}({it:str})
{cmdab:noleg:end} {cmdab:legpos:iton}({it:num}) {cmdab:legpos:iton}({it:num}) {cmdab:legcol:umns}({it:num}) {cmdab:legs:ize}({it:num}) {cmd:xsize}({it:num}) {cmd:ysize}({it:num})
Expand Down Expand Up @@ -58,7 +58,7 @@ respectively. In this case, it is better to define {opt ra:nge(0 100)} to contro
0-100, six cuts will split the data into 0,20,40,60,80,100. Or (100/5) + 1 because we also need to account for the starting value.
Please keep this in mind when defining this option.{p_end}

{p2coldent : {opt raformat(fmt)}}Format the values of the data range. The default format is {opt raformat(%5.0f)}.
{p2coldent : {opt format(fmt)}}Format the values of the data range. The default format is {opt format(%12.1f)}.
If your data ranges has decimal values, then it is advised to change the display to a reasonable format.{p_end}

{p2coldent : {opt ralabs:ize(str)}}The size of the range labels. The default format is {opt ralabs(1.8)}.{p_end}
Expand Down Expand Up @@ -134,8 +134,8 @@ See {browse "https://github.com/asjadnaqvi/stata-spider":GitHub} for examples.

{title:Package details}

Version : {bf:spider} v1.3
This release : 16 Feb 2024
Version : {bf:spider} v1.31
This release : 11 May 2024
First release: 13 Oct 2022
Repository : {browse "https://github.com/asjadnaqvi/stata-spider":GitHub}
Keywords : Stata, graph, spider plot
Expand All @@ -162,5 +162,5 @@ Please submit bugs, errors, feature requests on {browse "https://github.com/asja

{psee}
{helpb arcplot}, {helpb alluvial}, {helpb bimap}, {helpb bumparea}, {helpb bumpline}, {helpb circlebar}, {helpb circlepack}, {helpb clipgeo}, {helpb delaunay}, {helpb joyplot},
{helpb marimekko}, {helpb sankey}, {helpb schemepack}, {helpb spider}, {helpb streamplot}, {helpb sunburst}, {helpb treecluster}, {helpb treemap}
{helpb marimekko}, {helpb polarspike}, {helpb sankey}, {helpb schemepack}, {helpb spider}, {helpb streamplot}, {helpb sunburst}, {helpb treecluster}, {helpb treemap}, {helpb waffle}

4 changes: 2 additions & 2 deletions installation/stata.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
v 1.3
v 1.31
d 'SPIDER': A Stata package for spider plots
d
d Distribution-Date: 20240216
d Distribution-Date: 20240511
d
d Asjad Naqvi
d asjadnaqvi@gmail.com
Expand Down

0 comments on commit 3113b5e

Please sign in to comment.