Data visualization with SAS programming

Fun With SAS ODS Graphics: Drawing Mickey Mouse is as Easy as 1-2-3 (Ellipses)

Reply
Frequent Contributor
Frequent Contributor
Posts: 77

Fun With SAS ODS Graphics: Drawing Mickey Mouse is as Easy as 1-2-3 (Ellipses)

MICKEY.png

 

Just registered for SAS Global Forum 2017 at Walt Disney World in Orlando, so to mark the occasion, here's a quick SAS ODS Graphics take on the Mickey Mouse Template provided by Disney Family. Hope to M-I-C some of you in April!

 

* SAS ODS Graphics take on Mickey Mouse silhouette from family.disney.com/craft/mickey-mouse-template/;

data mickey;                                             * Generate chart data (grab coordinates from MS-Paintbrush);
imageSizeX=680; imageSizeY=593;                          * Image template width/height (px);

faceOriginX=340; faceOriginY=366;                        * Face points (circle);
faceTopCenterX=340; faceTopCenterY=147;
faceRadius=faceOriginY-faceTopCenterY;                   * Calculate face radius;
label="SGF 2017";                                        * Label for face;

leftEarOriginX=131; leftEarOriginY=131;                  * Left ear points (ellipse);
leftEarLeftCenterX=40; leftEarLeftCenterY=238;
leftEarTopCenterX=43; leftEarTopCenterY=49;              * Calculate left ear semimajor/semiminor lengths, slope;
leftEarSemiMajor=sqrt((leftEarOriginX-leftEarLeftCenterX)**2+(leftEarOriginY-leftEarLeftCenterY)**2);
leftEarSemiMinor=sqrt((leftEarOriginX-leftEarTopCenterX)**2+(leftEarOriginY-leftEarTopCenterY)**2);
leftEarSlope=-(leftEarLeftCenterY-leftEarOriginY)/(leftEarLeftCenterX-leftEarOriginX);

rightEarOriginX=551; rightEarOriginY=139;                * Right ear points (ellipse);
rightEarLeftCenterX=462; rightEarLeftCenterY=35;
rightEarTopCenterX=637; rightEarTopCenterY=52;           * Calculate right ear semimajor/semiminor lengths, slope;
rightEarSemiMajor=sqrt((rightEarOriginX-rightEarLeftCenterX)**2+(rightEarOriginY-rightEarLeftCenterY)**2);
rightEarSemiMinor=sqrt((rightEarOriginX-rightEarTopCenterX)**2+(rightEarOriginY-rightEarTopCenterY)**2);
rightEarSlope=-(rightEarLeftCenterY-rightEarOriginY)/(rightEarLeftCenterX-rightEarOriginX);

faceOriginY=imageSizeY-faceOriginY;                      * Adjust y-coordinates from top=0 to bottom=0;
leftEarOriginY=imageSizeY-leftEarOriginY;
leftEarTopCenterY=imageSizeY-leftEarTopCenterY;
rightEarOriginY=imageSizeY-rightEarOriginY;
rightEarTopCenterY=imageSizeY-rightEarTopCenterY;        

ods listing image_dpi=300 gpath='/folders/myfolders';    * Plot Mickey Mouse silhouette;
ods graphics on / reset antialias width=5in height=5in imagename="MICKEY";
proc template;
 define statgraph ellipseparm;
 begingraph; 
   entrytitle "M-I-C...SEE YOU REAL SOON!";     
   layout overlayequated /  
     xaxisopts=(display=(line ticks tickvalues) offsetmin=0.05 offsetmax=0.05)
     yaxisopts=(display=(line ticks tickvalues) offsetmin=0.05 offsetmax=0.05);
     ellipseparm xorigin=faceOriginX yorigin=faceOriginY              /* FACE */      
                 semimajor=faceRadius semiminor=faceRadius slope=0 /
                 fillattrs=(color=black) display=(fill);
     ellipseparm xorigin=leftEarOriginX yorigin=leftEarOriginY        /* LEFT EAR */ 
                 semimajor=leftEarSemiMajor semiminor=leftEarSemiMinor slope=leftEarSlope /
                 fillattrs=(color=black) display=(fill);
     ellipseparm xorigin=rightEarOriginX yorigin=rightEarOriginY      /* RIGHT EAR */ 
                 semimajor=rightEarSemiMajor semiminor=rightEarSemiMinor slope=rightEarSlope /
                 fillattrs=(color=black) display=(fill);
     textplot x=faceOriginX y=faceOriginY text=label /                /* LABEL */
                 position=center textattrs=(color=white size=28pt weight=bold);
   endlayout;
  endGraph;
 end;
run;
proc sgrender data=mickey template=ellipseparm;
run;

A NOTE ON DETERMINING POINT COORDINATES
So, was it difficult to find the coordinates of the points needed for the above chart? Not at all! Just cut-and-pasted the Disney-provided Mickey Mouse Template into Microsoft Paintbrush, drew a few lines to bisect the "face" and "ears", and hovered over the 8 needed points (starred below) to display the coordinates in the status bar.

 

MickeyPaintbrush.png

Trusted Advisor
Posts: 1,319

Re: Fun With SAS ODS Graphics: Drawing Mickey Mouse is as Easy as 1-2-3 (Ellipses)

Awesome as always @tc!!!

Super Contributor
Posts: 256

Re: Fun With SAS ODS Graphics: Drawing Mickey Mouse is as Easy as 1-2-3 (Ellipses)

Wow! So Awesome! Smiley Happy

Ask a Question
Discussion stats
  • 2 replies
  • 1042 views
  • 4 likes
  • 3 in conversation