BookmarkSubscribeRSS Feed
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

HalloweenWeb.png

 

With Trick-Or-Treat time coming up, here's a SAS ODS Graphics spider web spun from polygon, vector, and scatter plots using a formula found in Simple Model for the Mechanics of Spider Webs. Happy Halloween, all!

 

* Fun With SAS ODS Graphics: Oh What a Tangled Halloween Web We Weave
  Draws inspiration (and math!) from researchgate.net/publication/43021747_Simple_Model_for_the_Mechanics_of_Spider_Webs;

data spiderweb;                   * Generate points for spider web and spiders;
pi=constant("pi");
capM=4;                           * M=4 concentric polygons (spiral threads);
capN=10;                          * N=10 points for each polygon (radial threads);
L=1;                              * L=1 space between each polygon;
do m=1 to capM;                   * Generate polygon points (M polygons of N points);
  do n=1 to capN;
    theta=2*n*pi/capN;            * Polar coordinates (r, theta) = (m*L, 2*n*PI/N);
    r=m*L;                        
    x=r*cos(theta);               * Convert to x, y coordinates;
    y=r*sin(theta);
    output;
  end;
end;

m=.; x=.; y=.;
do n=1 to capN;                   * Generate points for N radial lines;      
  theta=2*n*pi/capN;              * Polar coordinates;
  r=capM*L+.1*capM/L;
  x2=r*cos(theta);                * Convert to x, y coordinates;
  y2=r*sin(theta);
  output;
end;

x2=.; y2=.;                       * Generate points for 5 spiders;  
y4=4.7;                           * y-coordinate for starting point of spiders' threads;   
x3=capM-2; y3=capM/-3; output;    * Five spiders;
x3=0; y3=capM/-1.5; output;
x3=3; y3=capM/2-1; output;
x3=-1.5; y3=-.5; output;
x3=-3; y3=1.5; output;
                                  * Let's weave a spider web with polygon, scatter, and vector plots!;
%sganno;                          * Use annotation to more precisely position title;    
data title;                              
%sgtext (label="HAPPY HALLOWEEN!", x1=50, y1=1, textsize=28, textweight='bold', anchor="bottom", x1space='layoutpercent', y1space='layoutpercent', width=100, widthunit='percent');
                              
ods graphics / width=5in height=6in noborder;
proc sgplot data=spiderweb aspect=1 noautolegend noborder nowall pad=0 sganno=title;
styleattrs backcolor=cxFF7518;                                  * cxFF7518 is Halloween orange;
symbolimage name=spider image="/home/ted.conway/spider.png";    * MS-Word spider icon saved as .png file;
polygon x=x y=y id=m / lineattrs=(color=white thickness=2.5pt); * Spiral threads;
vector x=x2 y=y2 / lineattrs=(color=white thickness=2.5pt);     * Radial threads;
scatter x=x y=y / markerattrs=(color=white) filledoutlinedmarkers markerfillattrs=(color=cxFF7518) markeroutlineattrs=(color=white thickness=2.5pt) markerattrs=(symbol=circlefilled size=9pt); * Show points;
scatter x=x3 y=y3 / markerattrs=(symbol=spider size=28pt);      * Spiders;
vector x=x3 y=y3 / xorigin=x3 yorigin=y4 noarrowheads lineattrs=(thickness=2.5pt); * Spider threads;
xaxis display=none offsetmin=0 offsetmax=0 values=(-4.7 4.7);   * Suppress and limit bounds of axes;
yaxis display=none offsetmin=0 offsetmax=0 values=(-4.7 4.7);
run;

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 0 replies
  • 1465 views
  • 6 likes
  • 1 in conversation