https://github.com/asjadnaqvi/stata-polarspike
A Stata package for polar spike graphs
https://github.com/asjadnaqvi/stata-polarspike
dataviz polar spike stata
Last synced: 7 months ago
JSON representation
A Stata package for polar spike graphs
- Host: GitHub
- URL: https://github.com/asjadnaqvi/stata-polarspike
- Owner: asjadnaqvi
- License: mit
- Created: 2024-05-09T07:52:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-18T20:30:53.000Z (over 1 year ago)
- Last Synced: 2025-03-10T06:34:46.256Z (7 months ago)
- Topics: dataviz, polar, spike, stata
- Language: Stata
- Homepage:
- Size: 11.6 MB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
README
     
[Installation](#Installation) | [Syntax](#Syntax) | [Examples](#Examples) | [Feedback](#Feedback) | [Change log](#Change-log)
---

# polarspike v1.0
(09 May 2024)## Installation
The package can be installed via SSC or GitHub. The GitHub version, *might* be more recent due to bug fixes, feature updates etc, and *may* contain syntax improvements and changes in *default* values. See version numbers below. Eventually the GitHub version is published on SSC.
The SSC version (**v1.0**):
```
ssc install polarspike, replace
```Or it can be installed from GitHub (**v1.0**):
```
net install polarspike, from("https://raw.githubusercontent.com/asjadnaqvi/stata-polarspike/main/installation/") replace
```The `palettes` package is required to run this command:
```
ssc install palettes, replace
ssc install colrspace, replace
```Even if you have the package installed, make sure that it is updated `ado update, update`.
If you want to make a clean figure, then it is advisable to load a clean scheme. These are several available and I personally use the following:
```
ssc install schemepack, replace
set scheme white_tableau
```You can also push the scheme directly into the graph using the `scheme(schemename)` option. See the help file for details or the example below.
I also prefer narrow fonts in figures with long labels. You can change this as follows:
```
graph set window fontface "Arial Narrow"
```## Syntax
The syntax for the latest version is as follows:
```stata
polarspike var [if] [in], by(var1) [ over(var2) ]
[ radmin(num) radmax(num) rotate(num) gap(num) palette(str) lwidth(str) format(str)
labcolor(str) labgap(num) labsize(str) ocolor(str) ogap(num) osize(str)
nolegend legsize(str) legposition(str) legcolumns(num) *
]```
See the help file `help polarspike` for details.
## Examples
Pull the data:
```stata
use "https://github.com/asjadnaqvi/stata-polarspike/blob/main/data/gdp_per_capita.dta?raw=true", clear
```Let's test the basic command:
```
polarspike rgdp_pc_ppp, by(countryname)
```
```
polarspike rgdp_pc_ppp, by(countryname) labgap(12) labsize(1) offset(10)
```
Rotation is great for optimizing the space:
```
polarspike rgdp_pc_ppp, by(countryname) labgap(8) labsize(1) offset(10) rotate(45)
```
Add colors by highlight different grouping in the graph:
```
polarspike rgdp_pc_ppp, by(countryname) labgap(8) labsize(1) offset(10) rotate(45) colorby(regionname)
```
```
polarspike rgdp_pc_ppp, by(countryname) labgap(8) labsize(1) offset(10) rotate(45) colorby(regionname) gap(0)
```
```
polarspike rgdp_pc_ppp, by(countryname) labgap(6) labsize(0.9) offset(10) rotate(45) colorby(regionname) gap(0) radmin(4) radmax(6) ///
title("Real GDP per capita in 2022 (constant 2017 USD)") note("Source: World Bank Open Data", size(1.2))
```
```
polarspike rgdp_pc_ppp, by(countryname) labgap(6) labsize(0.9) offset(10) rotate(45) colorby(regionname) gap(0) radmin(4) radmax(6) nolegend ///
title("Real GDP per capita in 2022 (constant 2017 USD)") note("Source: World Bank Open Data", size(1.2))
```
Condition the labels to only show values about a certain threshold:
```
polarspike rgdp_pc_ppp, by(countryname) labgap(6) labsize(0.9) offset(10) rotate(45) colorby(regionname) gap(0) radmin(4) radmax(6) nolegend labcond(10000) ///
title("Real GDP per capita in 2022 (constant 2017 USD)") note("Source: World Bank Open Data", size(1.2))
```
## Plotting change
```
polarspike change, by(countryname) labgap(6) labsize(0.9) offset(10) rotate(45) colorby(regionname) gap(0) radmin(4) radmax(6) ///
title("5-year change in real GDP per capita (PPP) (2017-2022)") note("Source: World Bank Open Data", size(1.2))
```
## Plotting by groups
```
polarspike rgdp_pc_ppp, by(countryname) over(regionname) labgap(8) labsize(1) offset(10) palette(CET C6) ///
title("Real GDP per capita in 2022 (constant 2017 USD)") note("Source: World Bank Open Data", size(1.2))
```
```
polarspike rgdp_pc_ppp, by(countryname) over(regionname) labgap(8) labsize(1) offset(10) palette(CET C6) radmin(4) radmax(7) ///
title("Real GDP per capita in 2022 (constant 2017 USD)") note("Source: World Bank Open Data", size(1.2))
```
```
polarspike change, by(countryname) over(regionname) labgap(6) labsize(0.9) offset(10) palette(CET C7) radmin(4) radmax(7) ///
title("Real GDP per capita in 2022 (constant 2017 USD)") note("Source: World Bank Open Data", size(1.2))
```
## Feedback
Please open an [issue](https://github.com/asjadnaqvi/stata-polarspike/issues) to report errors, feature enhancements, and/or other requests.
## Change log
**v1.0 (09 May 2024)**
- First release