%let name=polar_graph; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; /* New version of Sanjay's graph from this blog: http://blogs.sas.com/content/graphicallyspeaking/2016/07/02/polar-graph/ Except I fix the direction in the circular plot, and I use all sgplot (no sgrender). */ ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Polar Graph of black carbon concentration") style=htmlblue; ods graphics / noscale imagemap tipmax=25000 imagefmt=png imagename="&name" width=800px height=700px noborder; %let max_wind=25; /*--Generate some plausibly real random data--*/ data my_data; pi=constant("pi"); conv=pi/180.0; do wind_speed=0 to &max_wind by .5; do wind_direction=0 to 360 by 2; BCC=15 + 10*cos((wind_direction+wind_speed*5)*conv) + 5*cos((2*wind_direction+wind_speed*5)*conv); output; end; end; run; title1 c=gray33 h=14pt ls=1.3 "Black Carbon Concentration (BCC)"; title2 c=gray33 h=14pt "by wind speed and direction"; footnote c=gray77 h=11pt "Using random/simulated data"; proc sgplot data=my_data; label wind_direction='Wind Direction'; label wind_speed='Wind Speed'; scatter y=wind_speed x=wind_direction / colorresponse=bcc markerattrs=(symbol=squarefilled size=11) colormodel=(green yellow red) tip=(wind_direction wind_speed bcc); xaxis values=(0 to 360 by 90) valuesdisplay=('0/N' '90/E' '180/S' '270/W' '360/N') valueattrs=(color=gray33 size=11pt) labelattrs=(color=gray33 size=11pt weight=bold) offsetmin=0 offsetmax=0; yaxis offsetmin=0 offsetmax=0 valueattrs=(color=gray33 size=11pt) labelattrs=(color=gray33 size=11pt weight=bold) ; run; /* Now, let's plot it on circular axes... */ %let max_radius=35; /* convert to circular coordinates */ data my_data; set my_data; radius=wind_speed; angle_degrees=(360-wind_direction)+90; angle_radians=((2*pi)/360 )*(angle_degrees); y=radius*sin(angle_radians); x=radius*cos(angle_radians); run; /*--Add customizations to the graph--*/ data customize; /*--Generate radial axes--*/ x1=0; y1=0; x2= &max_wind*1.10; y2= 0; output; x1=0; y1=0; x2=-&max_wind*1.10; y2= 0; output; x1=0; y1=0; x2= 0; y2= &max_wind*1.10; output; x1=0; y1=0; x2= 0; y2=-&max_wind*1.10; output; x1=.; y1=.; x2=.; y2=.; /*--Generate radial axes labels--*/ x3= &max_wind*1.15; y3=0; label='E'; output; x3=-&max_wind*1.15; y3=0; label='W'; output; x3=0; y3= &max_wind*1.15; label='N'; output; x3=0; y3=-&max_wind*1.15; label='S'; output; x3=.; y3=.; label=''; /*--Generate circular axes--*/ do wind_ring=5 to &max_wind by 5; output; end; wind_ring=.; /*--Generate circular axes text labels--*/ do wind_ring=5 to &max_wind by 5; x4=wind_ring; y4=0; length label_circle $5; label_circle=trim(left(wind_ring)); output; end; x4=.; x4=.; label_circle=''; wind_ring=.; /*--'wind speed circles' text title--*/ x5=&max_wind/2; y5=-1; title_circle='Wind Speed Circles'; output; x5=.; y5=.; title_circle=''; /* footnote (to save space) */ x6=&max_wind*1.05; y6=&max_wind*1.15*-1; foot_text='Using random/simulated data'; output; run; data my_data; set my_data customize; run; ods html anchor='polar'; footnote; proc sgplot data=my_data aspect=1.0 noborder noautolegend; scatter x=x y=y / name='scatter' colorresponse=bcc markerattrs=(symbol=circlefilled size=11) colormodel=(green yellow red) tip=(wind_direction wind_speed bcc); gradlegend 'scatter'; xaxis display=none; yaxis display=none; /* north, south, east, west arrows */ vector x=x2 y=y2 / xorigin=x1 yorigin=y1 arrowheadshape=filled tip=none; text x=x3 y=y3 text=label / textattrs=(color=gray33 size=10 weight=bold) tip=none; /* circlular axes */ ellipseparm semimajor=wind_ring semiminor=wind_ring / xorigin=0 yorigin=0 /* tip=none */ lineattrs=(color=gray33); text x=x4 y=y4 text=label_circle / textattrs=(color=gray33 size=10 weight=bold) position=topleft contributeoffsets=none tip=none; text x=x5 y=y5 text=title_circle / textattrs=(color=gray33 size=11 weight=bold) position=bottom contributeoffsets=none tip=none; /* footnote in the graph space (to save space) */ text x=x6 y=y6 text=foot_text / textattrs=(color=gray77 size=11 weight=normal) position=left contributeoffsets=none tip=none; run; quit; ODS HTML CLOSE; ODS LISTING;