demo_nwplot

nwuse glasgow

nwplot

glasgow3

// Layout

nwplot, layout(mds, components(1))
nwplot, layout(circle)
nwplot, layout(grid)
nwplot, layout(grid, columns(20))

glasgow_grid

nwuse gang, nwclear

// Obtain coordinates from layout and plot with coordinates

nwplot, gen(coord)
replace coord_x = .2 if _n < 20
nwplot, nodexy(coord_x coord_y)

// Arcs

nwplot, arcstyle(automatic)
nwplot, arcstyle(straight)
nwplot, arcstyle(curved)
nwplot, arcbend(0.3) arcsplines(20)

// Factors

nwplot, nodefactor(2)
nwplot, edgefactor(2)
nwplot, arrowfactor(4)
nwplot, arrowbarbfactor(.2)
nwplot, nodefactor(2) edgefactor(4) arrowfactor(2) arrowbarbfactor(.2)

// Coloring of nodes

nwplot, color(Birthplace)
nwplot, color(Birthplace) colorpalette(red yellow cyan brown)

gang_color1

nwplot, color(Birthplace) scheme(s2network)

gang_color2

// Symbol of nodes

nwplot, symbol(Prison)
nwplot, symbol(Prison) symbolpalette(T S)

// Size of nodes

nwplot, size(Arrests)
nwplot, size(Arrests, forcekeys(1 5 10 20))

// All three

nwplot, size(Arrests, forcekeys(5 15 30)) color(Birthplace) symbol(Prison)

gang_all

// Schemes

nwplot, scheme(s1network)
nwplot, scheme(s3network)
nwplot, scheme(s2mono)

// Change the size and color of edges

nwplot gang, edgesize(gang)
nwgenerate blood = (gang==4)
nwplot blood
nwplot gang, size(Arrests) color(Birthplace) edgesize(gang) edgecolor(blood) 

gang_edges1

// Control the legend – legendopt()

nwplot gang, size(Arrests, forcekeys(5 10 20)) color(Birthplace, legendoff) edgesize(gang, legendoff) edgecolor(blood) legendopt(on pos(3) cols(1))

gang_edges2

// Control title and labels – twowayoptions

nwuse florentine
nwplot flobusiness, label(_label1)
nwplot flomarriage, label(_label1)
nwplot flobusiness, label(_label) edgecolor(flomarriage) edgecolorpalette(yellow red) title(“Florentine Businesses”, color(red) size(huge))

flo_edge1

// Control all plots – scatteropt() lineopt()

nwplot flomarriage, scatteropt(mfcolor(green) msize(ehuge) msymbol(D))

nwplot flomarriage, lineopt(lwidth(10) lcolor(green))
// Make animations

nwuse glasgow
nwmovie _all, titles((time 1) (time 2) (time 3), color(red))

movie

Leave a comment