-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20da6f6
commit a3c82e6
Showing
6 changed files
with
184 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
v 1.54 | ||
v 1.55 | ||
d 'TREEMAP': A Stata package for tree maps. | ||
d | ||
d Distribution-Date: 20240420 | ||
d Distribution-Date: 20240610 | ||
d | ||
d Asjad Naqvi | ||
d [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*! treemap v1.54 (20 Apr 2024) | ||
*! treemap v1.55 (10 Jun 2024) | ||
*! Asjad Naqvi ([email protected]) | ||
|
||
* v1.55 (10 Jun 2024): wrap() for label wraps. | ||
* v1.54 (20 Apr 2024): colorby() fixed. Now requires a variable name for the color order. | ||
* v1.53 (10 Apr 2024): Critical bug fix which was messing up the drawings if a third layer was defined. | ||
* v1.52 (20 Jan 2024): If by() variables had empty rows, the program was giving an error. These are now dropped by default. | ||
|
@@ -25,12 +26,11 @@ prog def treemap, sortpreserve | |
|
||
syntax varlist(numeric max=1) [if] [in], by(varlist min=1 max=3) /// | ||
[ XSize(real 5) YSize(real 3) format(str) palette(string) ADDTitles NOVALues NOLABels ] /// | ||
[ title(passthru) subtitle(passthru) note(passthru) scheme(passthru) name(passthru) saving(passthru) ] /// | ||
[ pad(numlist max=3) labprop labscale(real 0.3333) labcond(real 0) colorprop titlegap(real 0.1) titleprop LINEWidth(string) LINEColor(string) LABSize(string) ] /// // v1.1 options. labscale is undocumented labprop scaling | ||
[ fi(numlist max=3) ] /// // v1.2 options | ||
[ LABGap(string) ] /// // v1.3 options | ||
[ Share SFORmat(str) THRESHold(numlist max=1 >=0) fade(real 10) percent ] /// // v1.4, v1.5 options | ||
[ colorby(varname) sharevar(varname) ] | ||
[ colorby(varname) sharevar(varname) wrap(numlist >=0 max=1) * ] | ||
|
||
marksample touse, strok | ||
|
||
|
@@ -374,6 +374,42 @@ preserve | |
} | ||
|
||
|
||
// wrap | ||
if "`wrap'" != "" { | ||
|
||
// layer 0 | ||
gen _length0 = length(_l0_lab0) if _l0_lab0!= "" | ||
summ _length0, meanonly | ||
local _wraprounds0 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds0' { | ||
local wraptag = `wrap' * `i' | ||
replace _l0_lab0 = substr(_l0_lab0, 1, `wraptag') + "`=char(10)'" + substr(_l0_lab0, `=`wraptag' + 1', .) if _length0 > `wraptag' & _length0!=. | ||
} | ||
|
||
// layer 1 | ||
gen _length1 = length(_l0_lab1) if _l0_lab1!= "" | ||
summ _length1, meanonly | ||
local _wraprounds1 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds0' { | ||
local wraptag = `wrap' * `i' | ||
replace _l0_lab1 = substr(_l0_lab1, 1, `wraptag') + "`=char(10)'" + substr(_l0_lab1, `=`wraptag' + 1', .) if _length1 > `wraptag' & _length1!=. | ||
} | ||
|
||
// layer 2 | ||
gen _length2 = length(_l0_lab2) if _l0_lab2!= "" | ||
summ _length2, meanonly | ||
local _wraprounds2 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds2' { | ||
local wraptag = `wrap' * `i' | ||
replace _l0_lab2 = substr(_l0_lab2, 1, `wraptag') + "`=char(10)'" + substr(_l0_lab2, `=`wraptag' + 1', .) if _length2 > `wraptag' & _length2!=. | ||
} | ||
|
||
drop _length* | ||
} | ||
|
||
|
||
************** | ||
** layer1 ** | ||
|
@@ -434,6 +470,43 @@ preserve | |
replace _l1_`z'_lab0= "{it:" + _l1_`z'_lab1 + "}" if _l1_`z'_val >= `labcond' | ||
} | ||
|
||
|
||
// wrap | ||
if "`wrap'" != "" { | ||
|
||
// layer 0 | ||
gen _length0 = length(_l1_`z'_lab0) if _l1_`z'_lab0!= "" | ||
summ _length0, meanonly | ||
local _wraprounds0 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds0' { | ||
local wraptag = `wrap' * `i' | ||
replace _l1_`z'_lab0 = substr(_l1_`z'_lab0, 1, `wraptag') + "`=char(10)'" + substr(_l1_`z'_lab0, `=`wraptag' + 1', .) if _length0 > `wraptag' & _length0!=. | ||
} | ||
|
||
// layer 1 | ||
gen _length1 = length(_l1_`z'_lab1) if _l1_`z'_lab1!= "" | ||
summ _length1, meanonly | ||
local _wraprounds1 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds0' { | ||
local wraptag = `wrap' * `i' | ||
replace _l1_`z'_lab1 = substr(_l1_`z'_lab1, 1, `wraptag') + "`=char(10)'" + substr(_l1_`z'_lab1, `=`wraptag' + 1', .) if _length1 > `wraptag' & _length1!=. | ||
} | ||
|
||
// layer 2 | ||
gen _length2 = length(_l1_`z'_lab2) if _l1_`z'_lab2!= "" | ||
summ _length2, meanonly | ||
local _wraprounds2 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds2' { | ||
local wraptag = `wrap' * `i' | ||
replace _l1_`z'_lab2 = substr(_l1_`z'_lab2, 1, `wraptag') + "`=char(10)'" + substr(_l1_`z'_lab2, `=`wraptag' + 1', .) if _length2 > `wraptag' & _length2!=. | ||
} | ||
|
||
drop _length* | ||
} | ||
|
||
} | ||
|
||
} | ||
|
@@ -504,6 +577,43 @@ preserve | |
replace _l2_`z'_`y'_lab0 = "{it:" + _l2_`z'_`y'_lab1 + "}" in 1/`item2' if _l2_`z'_`y'_val >= `labcond' | ||
} | ||
|
||
|
||
// wrap | ||
if "`wrap'" != "" { | ||
|
||
// layer 0 | ||
gen _length0 = length(_l2_`z'_`y'_lab0) if _l2_`z'_`y'_lab0 != "" | ||
summ _length0, meanonly | ||
local _wraprounds0 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds0' { | ||
local wraptag = `wrap' * `i' | ||
replace _l2_`z'_`y'_lab0 = substr(_l2_`z'_`y'_lab0, 1, `wraptag') + "`=char(10)'" + substr(_l2_`z'_`y'_lab0, `=`wraptag' + 1', .) if _length0 > `wraptag' & _length0!=. | ||
} | ||
|
||
// layer 1 | ||
gen _length1 = length(_l2_`z'_`y'_lab1) if _l2_`z'_`y'_lab1 != "" | ||
summ _length1, meanonly | ||
local _wraprounds0 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds0' { | ||
local wraptag = `wrap' * `i' | ||
replace _l2_`z'_`y'_lab1 = substr(_l2_`z'_`y'_lab1, 1, `wraptag') + "`=char(10)'" + substr(_l2_`z'_`y'_lab1, `=`wraptag' + 1', .) if _length1 > `wraptag' & _length1!=. | ||
} | ||
|
||
|
||
// layer 2 | ||
gen _length2 = length(_l2_`z'_`y'_lab2) if _l2_`z'_`y'_lab2!= "" | ||
summ _length2, meanonly | ||
local _wraprounds2 = floor(`r(max)' / `wrap') | ||
|
||
forval i = 1 / `_wraprounds2' { | ||
local wraptag = `wrap' * `i' | ||
replace _l2_`z'_`y'_lab2 = substr(_l2_`z'_`y'_lab2, 1, `wraptag') + "`=char(10)'" + substr(_l2_`z'_`y'_lab2, `=`wraptag' + 1', .) if _length2 > `wraptag' & _length2!=. | ||
} | ||
|
||
drop _length* | ||
} | ||
|
||
} | ||
} | ||
|
@@ -679,7 +789,7 @@ preserve | |
xscale(off) yscale(off) /// | ||
xlabel(, nogrid) ylabel(, nogrid) /// | ||
xsize(`xsize') ysize(`ysize') /// | ||
`title' `subtitle' `note' `scheme' `name' `saving' | ||
`options' | ||
|
||
*/ | ||
restore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{smcl} | ||
{* 20Apr2024}{...} | ||
{* 10Jun2024}{...} | ||
{hi:help treemap}{...} | ||
{right:{browse "https://github.com/asjadnaqvi/stata-treemap":treemap v1.54 (GitHub)}} | ||
{right:{browse "https://github.com/asjadnaqvi/stata-treemap":treemap v1.55 (GitHub)}} | ||
|
||
{hline} | ||
|
||
|
@@ -22,7 +22,7 @@ and on the Python's {browse "https://github.com/laserson/squarify":squarify} alg | |
{cmd:[} {cmdab:xs:ize}({it:num}) {cmdab:ys:ize}({it:num}) {cmd:format}({it:str}) {cmd:share} {cmd:sformat}({it:str}) {cmd:palette}(it:str) {cmd:colorby}({it:var}) | ||
{cmd:pad}({it:list}) {cmdab:labs:ize}({it:list}) {cmdab:linew:idth}({it:list}) {cmdab:linec:olor}({it:list}) {cmd:fi}({it:list}) {cmd:labcond}({it:num}) | ||
{cmdab:addt:itles} {cmdab:noval:ues} {cmdab:nolab:els} {cmdab:labs:ize}({it:num}) {cmd:titlegap}({it:num}) {cmdab:labg:ap}({it:str}) | ||
{cmdab:thresh:old}({it:num}) {cmd:fade}({it:num}) {cmd:labprop} {cmd:titleprop} {cmd:labscale}({it:num}) {cmd:colorprop} | ||
{cmdab:thresh:old}({it:num}) {cmd:fade}({it:num}) {cmd:labprop} {cmd:titleprop} {cmd:labscale}({it:num}) {cmd:colorprop} {cmd:wrap}({it:num}) | ||
{cmd:title}({it:str}) {cmd:subtitle}({it:str}) {cmd:note}({it:str}) {cmd:scheme}({it:str}) {cmd:name}({it:str}) {cmd:saving}({it:str}) {cmd:]} | ||
|
||
|
||
|
@@ -69,6 +69,8 @@ in combination with {opt percent} then the threshold will use the percentage val | |
{p2coldent : {opt pad(numlist max=3)}}The padding of the boxes, which can be defined as a list. The default values are {opt :pad(0.012 0.01 0.01)} for the three layers. A value of 0 | ||
implies no padding. If you change the {opt xsize} and {opt ysize} substantially, then you might also need to update the padding.{p_end} | ||
|
||
{p2coldent : {opt wrap(num)}}Wrap the labels after a number of characters. A good starting point for very long labels is {opt wrap(50)}.{p_end} | ||
|
||
{p2coldent : {opt labs:ize(string max=3)}}The size of the labels. The default values are {opt labs(1.6 1.6 1.6)}. If only one value is specified, it will passed on to all the layers.{p_end} | ||
|
||
{p2coldent : {opt linew:idth(string max=3)}}The line width of the boxes. The default values are {opt linew(0.03 0.03 0.03)}. If only one value is specified, it will passed on to all the layers.{p_end} | ||
|
@@ -128,8 +130,8 @@ Please submit bugs, errors, feature requests on {browse "https://github.com/asja | |
|
||
{title:Package details} | ||
|
||
Version : {bf:treemap} v1.54 | ||
This release : 20 Apr 2024 | ||
Version : {bf:treemap} v1.55 | ||
This release : 10 Jun 2024 | ||
First release: 08 Sep 2022 | ||
Repository : {browse "https://github.com/asjadnaqvi/treemap":GitHub} | ||
Keywords : Stata, graph, treemap, squarify | ||
|
@@ -140,6 +142,23 @@ E-mail : [email protected] | |
Twitter : {browse "https://twitter.com/AsjadNaqvi":@AsjadNaqvi} | ||
|
||
|
||
|
||
{title:Citation guidelines} | ||
|
||
Suggested citation guidlines for this package: | ||
|
||
Naqvi, A. (2024). Stata package "treemap" version 1.55. Release date 10 June 2024. https://github.com/asjadnaqvi/stata-treemap. | ||
|
||
@software{treemap, | ||
author = {Naqvi, Asjad}, | ||
title = {Stata package ``treemap''}, | ||
url = {https://github.com/asjadnaqvi/stata-treemap}, | ||
version = {1.55}, | ||
date = {2024-06-10} | ||
} | ||
|
||
|
||
|
||
{title:References} | ||
|
||
{p 4 8 2}Bruls, M., Huizing, K., van Wijk Jarke J. (2000). {browse "https://link.springer.com/chapter/10.1007/978-3-7091-6783-0_4":Squarified Treemaps}. Data Visualization 2000, Eurographics. | ||
|
@@ -157,4 +176,6 @@ Twitter : {browse "https://twitter.com/AsjadNaqvi":@AsjadNaqvi} | |
|
||
{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 waffle} | ||
{helpb marimekko}, {helpb polarspike}, {helpb sankey}, {helpb schemepack}, {helpb spider}, {helpb streamplot}, {helpb sunburst}, {helpb treecluster}, {helpb treemap}, {helpb waffle} | ||
|
||
or visit {browse "https://github.com/asjadnaqvi":GitHub} for detailed documentation and examples. |