help spiderspider v1.31 (GitHub)

spider

: A Stata package for spider plots.

The command is based on the following guide on Medium: Spider plots.

Syntax

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
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)
title(str) subtitle(str) note(str) scheme(str) name(str) saving(str)
]

spider var, by(var) The command requires a numerical variable where the data is in long form. The data is split by by() categories across the circle.
If there are more observations per by() category, the command will collapse and average the data.
So make sure to control the data before using the spider command in case you to plot other summary statistics.

over(var) The over() defines the different spider categories. These variables show up in the legend.

alpha(num) The transparency control of the spider area fills. The value ranges from 0-100, where 0 is no fill and 100 is fully filled.
Default value is 10 or 10% transparency.

rotate(num) Rotate the graph in degrees. The default value is 30 or 30 degrees to prevent overlab with range values.

smooth(num) This option allows users to smooth out the spider plots using splines. It can take on values between [0,1]
where 0 = tighter curves and 1 = wider curves. A value of 0.5 is a reasonable middle ground.
If the points are close to each other or there are large data spikes, then the smoothing might result in "twisting" or creating a loop for the splines.
In this case, it is advised to use a smaller smooth()} value, or extend the range of the circles so points are reasonable better spaced.

palette(name) Color name is any named scheme defined in the colorpalette package.
Default is tableau.

range(min max) Use this option to define the range of the graph. Default values are the minimum and maximum of all the data
points that are offset by 10% of the data range. This might not be optimal in all cases. For example, if you know that your data is between 0-100,
but the actual values are between 40-80, the graph range will automatically adjust the ranges to 36 and 84, or 40-0.1*(80-40) and 80+0.1*(80-40)
respectively. In this case, it is better to define range(0 100) to control the scaling.

cuts(num) The number of cuts to show in the graph as rings. Default value is cuts(6). For example, if the range is
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.

format(fmt) Format the values of the data range. The default format is format(%12.1f).
If your data ranges has decimal values, then it is advised to change the display to a reasonable format.

ralabsize(str) The size of the range labels. The default format is ralabs(1.8).

ralabcolor(str) The color of the range labels. The default format is ralabc(black).

ralabangle(str) The angle of the range labels. The default format is ralaba(0) for horizontal.

lwidth(num) The outline width of the spider area fill. Default is lw(0.3).
Area fill lines can be turned off by defining lw(none).

msymbol(str) The marker symbol on the spider lines. Default is msym(circle).
Markers can be turned off by defining msymb(none).

msize(str) The marker size on the spider lines. Default is ms(0.3).

mlwidth(str) The marker line size on the spider lines. Default is mlw(0.3).
For example, if you are using a hollow circle or msym(Oh), then increasing its outline width makes it more prominent.

nolegend Hide the legend.

legposition(num) Clock position of the legend. Default is legpos(6).

legcolumns(num) Number of legend columns. Default is legcol(3).

legsize(num) Size of legend entries. Default is legs(2.2).

displacespike(num) Defines how much the spikes should be extended beyond the circle extent.
The default value is displaces(2) for 2%.

displacelab(num) Push over() labels away from the spikes. The default value is displacel(15) or 15% of spike length.

ccolor(str) The color of the circles. Default is cc(gs12).

cwidth(str) The width of the circles. Default is cw(0.1).

scolor(str) The color of the spikes. Default is sc(gs12).

swidth(str) The width of the spikes. Default is sw(0.1).

rotatelabel Rotate the spike labels by 90 degrees.

slabsize(str) The width of the spike labels. Default is slabs(2.2).

slabcolor(str) The color of the spike labels. Default is slabc(black).

xsize(num), ysize(num) Dimensions of the graph. Defaults are xsize(1) and ysize(1).

title, subtitle, note These are standard twoway graph options.

scheme(string) Load the custom scheme. Above options can be used to fine tune individual elements.

name(string) Assign a name to the graph.

Dependencies

The palette package (Jann 2018, 2022) is required for spider:

ssc install palettes, replace
ssc install colrspace, replace

Even if you have these installed, it is highly recommended to update the dependencies:
ado update, update

Examples

See GitHub for examples.

Package details

Version : spider v1.31
This release : 11 May 2024
First release: 13 Oct 2022
Repository : GitHub
Keywords : Stata, graph, spider plot
License : MIT

Author : Asjad Naqvi
E-mail : asjadnaqvi@gmail.com
Twitter : @AsjadNaqvi

Feedback

Please submit bugs, errors, feature requests on GitHub by opening a new issue.

References

Jann, B. (2018). Color palettes for Stata graphics. The Stata Journal 18(4): 765-785.

Jann, B. (2022). Color palettes for Stata graphics: An update. University of Bern Social Sciences Working Papers No. 43.

Other visualization packages

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