Skip to content

Commit

Permalink
v1.81
Browse files Browse the repository at this point in the history
  • Loading branch information
asjadnaqvi committed Aug 22, 2023
1 parent ce91c33 commit 00a8446
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 21 deletions.
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

---

# bimap v1.8
(26 Jun 2023)
# bimap v1.81
(22 Aug 2023)

This package provides the ability to draw bi-variate maps in Stata. It is based on the [Bi-variate maps Guide](https://medium.com/the-stata-guide/stata-graphs-bi-variate-maps-b1e96dd4c2be).

Expand All @@ -20,12 +20,12 @@ This package provides the ability to draw bi-variate maps in Stata. It is based

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. All examples are updated to the latest version and might not be compatible with the old ones. Please check the documentation and change logs.

The package can be installed from SSC (**v1.7**):
The package can be installed from SSC (**v1.8**):
```
ssc install bimap, replace
```

Or it can be installed from GitHub (**v1.8**):
Or it can be installed from GitHub (**v1.81**):

```
net install bimap, from("https://raw.githubusercontent.com/asjadnaqvi/stata-bimap/main/installation/") replace
Expand Down Expand Up @@ -62,12 +62,12 @@ This command is a wrapper for `spmap` and assumes that you have shapefiles in St

## Syntax

The syntax for **v1.8** is as follows:
The syntax for the latest version is as follows:

```stata
bimap vary varx [if] [in], [ palette(name) reverse clr0(str) clrx(str) clry(str) clrsaturate(num)
cut(pctile|equal) cutx(numlist) cuty(numlist) binsproper bins(num >=2) binx(num >=2) biny(num >=2) values count
percent showlegend ocolor(str) osize(str) ndocolor(str) ndfcolor(str) xdiscrete ydiscrete labxgap(num) labygap(num)
percent showlegend ocolor(str) osize(str) ndocolor(str) ndfcolor(str) ndsize(str) xdiscrete ydiscrete labxgap(num) labygap(num)
textx(str) texty(str) textlabsize(num) textsize(num) formatx(str) formaty(str) xscale(num) yscale(num)
polygon(options) line(options) point(options) label(options) arrow(options) diagram(options) scalebar(options)
title(str) subtitle(str) note(str) name(str) scheme(str) ]
Expand Down Expand Up @@ -304,8 +304,6 @@ bimap share_hisp share_afam using county_shp2, cut(pctile) palette(census) ///
<img src="/figures/bimap12.png" height="500">


### if statements

```
bimap share_hisp share_afam using county_shp2, cut(pctile) palette(census) ///
note("Data from the US Census Bureau.", size(small)) ///
Expand Down Expand Up @@ -476,13 +474,44 @@ bimap discy discx using county_shp2, palette(yellowblue) values count xdisc ydis

<img src="/figures/bimap23_3.png" height="500">


### missing data fixed (v1.81)

```
use county, clear
destring _all, replace
merge 1:1 STATEFP COUNTYFP using county_race
keep if _m==3
drop _m
replace share_hisp = . if stname=="Texas"
keep share_hisp share_afam _ID stname
sort _ID
*** format check 2 (fix decimals)
bimap share_hisp share_afam using county_shp2, palette(orangeblue) ///
ndfcolor(pink) ndocolor(lime) ndsize(0.3) ///
values count ///
polygon(data("state_shp2") ocolor(black) osize(0.2))
```

<img src="/figures/bimap24.png" height="500">

## Feedback

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


## Change log

**v1.81 (22 Aug 2023)**
- Fixed a bug where missing data points where getting dropped (reported by Steve Johnson).
- Fixed passthru of the `ndisze()` option.


**v1.8 (26 Jun 2023)**
- Changed the ways `cutx()` and `cuty()` are calculated (requested by Paul Hufe). These now take on lists which are used as provided.
- Removed `textgap()` that was left over from the old legend code.
Expand Down
Binary file added figures/bimap24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions installation/bimap.ado
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*! bimap v1.8 (26 Jun 2023)
*! bimap v1.81 (22 Aug 2023)
*! Asjad Naqvi ([email protected])

* v1.81 (22 Aug 2023): Fixed a bug where missing data was getting dropped. ndsize() passthru fixed.
* v1.8 (26 Jun 2023): custom cuts now take on values given in list, textgap() removed, labxgap(), labygap() added. Legend label positions optimized.
* v1.7 (15 Jun 2023): added support for binary variables: xdiscrete, ydiscrete
* v1.62 (19 May 2023): Fix to legend labels and sizes. Minor improvements.
Expand Down Expand Up @@ -74,7 +75,7 @@ version 15
exit
}

marksample touse, strok
marksample touse, strok novarlist
gettoken var2 var1 : varlist // var1 = x, var2 = y


Expand Down Expand Up @@ -109,6 +110,8 @@ qui {

tempvar cat_`var1' cat_`var2'



summ `var1', meanonly
local xmin = r(min)
local xmax = r(max)
Expand Down Expand Up @@ -478,6 +481,8 @@ qui {
local ndo = cond("`ndocolor'" == "", "gs12", "`ndocolor'")

local ndf = cond("`ndfcolor'" == "", "gs8", "`ndfcolor'")

local nds = cond("`ndsize'" == "", "`lw'", "`ndsize'")

local leg = cond("`showlegend'"=="", "legend(off)", "`legend'")

Expand Down Expand Up @@ -519,13 +524,14 @@ qui {
spmap `grp_cut' using "`using'", ///
id(_ID) clm(custom) clb(0(1)`cutst') fcolor("`colors'") ///
ocolor(`lc' ..) osize(`lw' ..) ///
ndocolor(`ndo' ..) ndsize(`lw' ..) ndfcolor(`ndf' ..) ///
ndocolor(`ndo' ..) ndsize(`nds' ..) ndfcolor(`ndf' ..) ///
`polygon' `line' `point' `label' ///
`leg' `legstyle' `legenda' `legendstyle' `legjunction' `legcount' `legorder' `legtitle' /// // v1.4 legend passthrus
`arrow' `diagram' `scalebar' /// // v1.5 passthrus
name(_map, replace) nodraw


*/

**************************
**** Legend *****
Expand Down
6 changes: 3 additions & 3 deletions installation/bimap.pkg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v 1.8
v 1.81
d {bf:BIMAP}: Bi-variate maps

d Requires: Stata version 15 or higher.
Expand All @@ -7,9 +7,9 @@ d KW: Stata
d KW: graphs
d KW: map
d KW: bivariate map
d Distribution-Date: 20230626
d Distribution-Date: 20230822
d
d This version: 26 Jun 2023
d This version: 22 Aug 2023
d First version: 08 Apr 2022
d License: MIT
d
Expand Down
13 changes: 8 additions & 5 deletions installation/bimap.sthlp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{smcl}
{* 26Jun2023}{...}
{* 22Aug2023}{...}
{hi:help bimap}{...}
{right:{browse "https://github.com/asjadnaqvi/stata-bimap":bimap v1.8 (GitHub)}}
{right:{browse "https://github.com/asjadnaqvi/stata-bimap":bimap v1.81 (GitHub)}}

{hline}

Expand All @@ -17,7 +17,7 @@ Note that {cmd:bimap} only works if you have processed the shapefiles using Stat

{cmd:bimap} {it:vary varx} {ifin}, {cmd:[} {cmd:palette}({it:name}) reverse {cmd:clr0}({it:str}) {cmd:clrx}({it:str}) {cmd:clry}({it:str}) {cmdab:clrsat:urate}({it:num})
{cmd:cut}({it:pctile}|{it:equal}) {cmd:cutx}({it:numlist}) {cmd:cuty}({it:numlist}) {cmd:binsproper} {cmd:bins}({it:num >=2}) {cmd:binx}({it:num >=2}) {cmd:biny}({it:num >=2}) {cmd:values} {cmd:count}
{cmd:percent} {cmdab:showleg:end} {cmd:ocolor}({it:str}) {cmd:osize}({it:str}) {cmd:ndocolor}({it:str}) {cmd:ndfcolor}({it:str}) {cmdab:xdisc:rete} {cmdab:ydisc:rete} {cmd:labxgap}({it:num}) {cmd:labygap}({it:num})
{cmd:percent} {cmdab:showleg:end} {cmd:ocolor}({it:str}) {cmd:osize}({it:str}) {cmd:ndocolor}({it:str}) {cmd:ndfcolor}({it:str}) {cmd:ndfsize}({it:str}) {cmdab:xdisc:rete} {cmdab:ydisc:rete} {cmd:labxgap}({it:num}) {cmd:labygap}({it:num})
{cmd:textx}({it:str}) {cmd:texty}({it:str}) {cmdab:textlabs:ize}({it:num}) {cmdab:texts:ize}({it:num}) {cmd:formatx}({it:str}) {cmd:formaty}({it:str}) {cmd:xscale}({it:num}) {cmd:yscale}({it:num})
{cmd:polygon}({it:options}) {cmd:line}({it:options}) {cmd:point}({it:options}) {cmd:label}({it:options}) {cmd:arrow}({it:options}) {cmd:diagram}({it:options}) {cmd:scalebar}({it:options})
{cmd:title}({it:str}) {cmd:subtitle}({it:str}) {cmd:note}({it:str}) {cmd:name}({it:str}) {cmd:scheme}({it:str}) {cmd:]}
Expand Down Expand Up @@ -74,6 +74,8 @@ also be defined using {opt binx()} and/or {opt biny()}. The default is {opt bin(

{p2coldent : {opt ndfcolor(str)}}Fill color of polygons with no data. Same as in {cmd:spmap}. Default value is {it:gs8}.{p_end}

{p2coldent : {opt ndsize(str)}}Line width of missing observations. If no value is specified, it defaults to the {opt osize()} value.{p_end}

{p2coldent : {opt polygon}(), {opt line}(), {opt point}(), {opt label}()}These are {cmd:spmap} passthru options for additional layers. See {stata help spmap} for details.{p_end}

{p2coldent : {opt arrow}(), {opt diagram}(), {opt scalebar}()}These are {cmd:spmap} passthru options for additional layers. See {stata help spmap} for details.{p_end}
Expand Down Expand Up @@ -139,8 +141,8 @@ Please see {browse "https://github.com/asjadnaqvi/stata-bimap":GitHub} for examp

{title:Package details}

Version : {bf:bimap} v1.8
This release : 26 Jun 2023
Version : {bf:bimap} v1.81
This release : 22 Aug 2023
First release: 08 Apr 2022
Repository : {browse "https://github.com/asjadnaqvi/stata-bimap":GitHub}
Keywords : Stata, map, bimap, bi-variate
Expand All @@ -155,6 +157,7 @@ Twitter : {browse "https://twitter.com/AsjadNaqvi":@AsjadNaqvi}
{title:Acknowledgements}

{p 4 4 2}
Steve Johnson found a bug with missing data getting dropped (v1.81). ndsize() passthru fixed.
Paul Hufe requested changes to custom cut-offs (v1.8).
Several requests for allowing categorical variables (v1.7)
Kit Baum, Fayssal Ayad, and Paul reported bug in the bimap v1.6 legends (v1.62, v1.61).
Expand Down
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.8
v 1.81
d BIMAP: A package for creating bi-variate maps.
d
d Distribution-Date: 20230626
d Distribution-Date: 20230822
d
d Asjad Naqvi
d [email protected]
Expand Down

0 comments on commit 00a8446

Please sign in to comment.