<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Overlay Square in Heatmap in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409567#M14029</link>
    <description>&lt;P&gt;I&amp;nbsp;think I would merge the data with the coordinates of the corners of the strike zone and use a POLYGON statement to draw the rectangle,&amp;nbsp;as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data coded_hits_num;
do x = -1 to 1 by 0.1;
   do z = 1 to 3 by 0.1;
      p = 1 - (x**2 + (z-2)**2) / 4;
      hits = rand("Binomial", p, 100);
      output;
   end;
end;
run;

data strikeZone;
ID = "S";
input xPoly zPoly;
datalines;
-1 1
 1 1
 1 3
-1 3
;

data all;
merge coded_hits_num strikezone;
run;

proc sgplot data=all aspect=1 noautolegend;
	heatmap x=x y=z / freq=hits colormodel=(blue yellow red) nxbins=21 nybins=21;
   polygon ID=ID x=xPoly y=zPoly / lineattrs=(thickness=5);
   xaxis min=-2 max=2;
   yaxis min=0 max=4;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot58.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16371i959CAD8E96886395/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPlot58.png" alt="SGPlot58.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2017 17:51:31 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-11-01T17:51:31Z</dc:date>
    <item>
      <title>Overlay Square in Heatmap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409456#M14026</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a heat map of a strike zone in baseball. The data contains the x and y values for where the ball crossed the plate, and also whether it was hit or not. I'd like to create a heat map showing the best areas of contact, along with overlaying the strike zone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally, the strike zone would just be a box from coordinates (-1,1), (1,1), (-1,3), (1,3).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code for the heatmap, which doesn't include whether or not contact was made:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=coded_hits_num;
	heatmap x=plate_x y=plate_z / colormodel=(blue yellow red);
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 13:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409456#M14026</guid>
      <dc:creator>jl1005</dc:creator>
      <dc:date>2017-11-01T13:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay Square in Heatmap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409462#M14027</link>
      <description>This is the place to look:
&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/&lt;/A&gt;
Has examples of every graph imaginable.  A quick search shows plenty of overlay examples:
&lt;A href="https://blogs.sas.com/content/?s=overlay+shape" target="_blank"&gt;https://blogs.sas.com/content/?s=overlay+shape&lt;/A&gt;</description>
      <pubDate>Wed, 01 Nov 2017 13:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409462#M14027</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-01T13:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay Square in Heatmap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409463#M14028</link>
      <description>&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2016/08/08/outline-cells-table-using-heat-map/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2016/08/08/outline-cells-table-using-heat-map/&lt;/A&gt;

See my blog:
Outline cells in a table using a heat map</description>
      <pubDate>Wed, 01 Nov 2017 13:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409463#M14028</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-11-01T13:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay Square in Heatmap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409567#M14029</link>
      <description>&lt;P&gt;I&amp;nbsp;think I would merge the data with the coordinates of the corners of the strike zone and use a POLYGON statement to draw the rectangle,&amp;nbsp;as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data coded_hits_num;
do x = -1 to 1 by 0.1;
   do z = 1 to 3 by 0.1;
      p = 1 - (x**2 + (z-2)**2) / 4;
      hits = rand("Binomial", p, 100);
      output;
   end;
end;
run;

data strikeZone;
ID = "S";
input xPoly zPoly;
datalines;
-1 1
 1 1
 1 3
-1 3
;

data all;
merge coded_hits_num strikezone;
run;

proc sgplot data=all aspect=1 noautolegend;
	heatmap x=x y=z / freq=hits colormodel=(blue yellow red) nxbins=21 nybins=21;
   polygon ID=ID x=xPoly y=zPoly / lineattrs=(thickness=5);
   xaxis min=-2 max=2;
   yaxis min=0 max=4;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot58.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16371i959CAD8E96886395/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPlot58.png" alt="SGPlot58.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 17:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Overlay-Square-in-Heatmap/m-p/409567#M14029</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-11-01T17:51:31Z</dc:date>
    </item>
  </channel>
</rss>

