<?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: Creating Custom legend in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732208#M21312</link>
    <description>&lt;P&gt;If you don't want to go with creating a custom legend with annotate, here's a way you might use a gplot legend... This example creates a gmap and suppresses the gmap legend, then creates a gplot using the same data (keeping the gplot legend, basically suppressing the gplot graph). You'll probably have some variable other than statecode to color the graphs by.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only played around with this for a few minutes - you can probably make some improvements! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data foo; set sashelp.us_data (where=(statecode in ('NC' 'SC' 'GA')));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;goptions xpixels=500 ypixels=500;&lt;BR /&gt;proc &lt;STRONG&gt;gmap&lt;/STRONG&gt; data=foo map=maps.us;&lt;BR /&gt;id statecode;&lt;BR /&gt;choro &lt;STRONG&gt;statecode&lt;/STRONG&gt; / discrete nolegend;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;symbol1 font='albany amt/unicode' value='25a0'x interpol=none h=.00001;&lt;BR /&gt;legend1 label=('My Legend') shape=symbol(.25in,.25in) repeat=1;&lt;BR /&gt;title; footnote;&lt;BR /&gt;goptions xpixels=600 ypixels=50;&lt;BR /&gt;proc gplot data=foo;&lt;BR /&gt;plot population_2010*population_2010=&lt;STRONG&gt;statecode&lt;/STRONG&gt; / legend=legend1&lt;BR /&gt;noaxes noframe;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="map_legend.png" style="width: 500px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57119iA62461042C7442F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="map_legend.png" alt="map_legend.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plot_legend.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57120i4C05638E865B0076/image-size/large?v=v2&amp;amp;px=999" role="button" title="plot_legend.png" alt="plot_legend.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 13:04:07 GMT</pubDate>
    <dc:creator>GraphGuy</dc:creator>
    <dc:date>2021-04-08T13:04:07Z</dc:date>
    <item>
      <title>Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732007#M21298</link>
      <description>&lt;P&gt;I need a way to produce only a legend which can be used on a panel in a template I have created.&amp;nbsp; It's nothing fancy, just a title, 4 colored squares (with Hex or color name specified) with some text next to each.&amp;nbsp; I've seen some SAS programming use gplot to produce only a legend, but that isn't working for my purposes.&amp;nbsp; I came across Lex Jansen's page on it, but wasn't able to use that either.&amp;nbsp; Anyone have some canned SAS code that will do this?&amp;nbsp; I just need a way to call it in PROC GREPLAY so that I can add it to a template.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 18:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732007#M21298</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2021-04-07T18:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732016#M21299</link>
      <description>&lt;P&gt;It may help to show the "template" you have created so we have some idea what you are working with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would likely be a good idea to show what a completed graph with this might look like and the bits that you are asking for highlighted.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 18:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732016#M21299</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-07T18:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732028#M21300</link>
      <description>Are you using GTL, SGPLOT or GPLOT? Or something else? That will matter....</description>
      <pubDate>Wed, 07 Apr 2021 19:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732028#M21300</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-07T19:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732032#M21301</link>
      <description>I am using GMAP (nolegend option) and GSLIDE outputs on the template.&lt;BR /&gt; Legend would apply to the GMAP outputs universally.&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Apr 2021 19:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732032#M21301</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2021-04-07T19:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732048#M21302</link>
      <description>Ok. I think I don't know enough to answer your question. I would have assumed that you could just use GMAP and then get the legend within there customized. I would use formats to get the hex code shown as desired instead of the labels.  &lt;BR /&gt;&lt;A href="https://robslink.com/SAS/democd66/aaaindex.htm" target="_blank"&gt;https://robslink.com/SAS/democd66/aaaindex.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Either way, I've moved this post to the graphics forum so hopefully one of the graphics guru's can assist you soon &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;FYI - SGMAP makes much better maps these days.</description>
      <pubDate>Wed, 07 Apr 2021 19:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732048#M21302</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-07T19:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732076#M21303</link>
      <description>&lt;P&gt;This should be doable using SGPLOT procedure with a "dummy" scatter plot statement and sashelp.class.&amp;nbsp; The dummy plot is needed to allow the plot output to be created.&amp;nbsp; Transparency=1 can be used to suppress any actual plot display.&amp;nbsp; Other options can be used to suppress axes and borders.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, use one or more LEGENDITEM statements to define named legend entries you need, including color, type of item and the associated text.&amp;nbsp; Then, add the names of the legend items to the KEYLEGEND statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do the same with GTL too.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See use of LegendItem in this example:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2017/10/27/legend-items/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2017/10/27/legend-items/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also see documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=grstatproc&amp;amp;docsetTarget=p0hc32jtfqoy1fn1h5i38q8v9py2.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=grstatproc&amp;amp;docsetTarget=p0hc32jtfqoy1fn1h5i38q8v9py2.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=grstatproc&amp;amp;docsetTarget=p0xmbppzx71smbn1203aaif96z86.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=grstatproc&amp;amp;docsetTarget=p0xmbppzx71smbn1203aaif96z86.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 19:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732076#M21303</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2021-04-07T19:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732106#M21304</link>
      <description>&lt;P&gt;Here is an example:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics / noborder;
proc sgplot data=sashelp.class noborder;
scatter x=height y=weight / group=sex transparency=1;
xaxis display=none;
yaxis display=none;
legenditem type=fill name='Item1' / fillattrs=graphdata2 label='Custom 1';
legenditem type=line name='Item2' / lineattrs=graphdata3 label='Custom 2';
keylegend 'Item1' 'Item2' / scale=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Apr 2021 22:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732106#M21304</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2021-04-07T22:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732187#M21308</link>
      <description>&lt;P&gt;Oh no.&lt;BR /&gt;&lt;BR /&gt;Was the LEGENDITEM option added recently? When I copy this code and run it those options appear in red and I get an invalid statement error for those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like we may have to call upon the macro gurus...&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 12:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732187#M21308</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2021-04-08T12:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732197#M21310</link>
      <description>&lt;P&gt;Since you're using SAS/Graph (gmap, gslide, greplay), you will not be able to easily use ODS Graphics (sgplot) with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One solution I've used to get a second legend on a separate page in SAS/Graph is to suppress the legend in the real graph (nolegend), and then use 'annotate' on a blank gslide to fabricate my own custom legend on a separate page. Here's an example - the outtput, and then the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://robslink.com/SAS/democd16/topper.htm" target="_blank"&gt;http://robslink.com/SAS/democd16/topper.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://robslink.com/SAS/democd16/topper.sas" target="_blank"&gt;http://robslink.com/SAS/democd16/topper.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 12:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732197#M21310</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2021-04-08T12:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732208#M21312</link>
      <description>&lt;P&gt;If you don't want to go with creating a custom legend with annotate, here's a way you might use a gplot legend... This example creates a gmap and suppresses the gmap legend, then creates a gplot using the same data (keeping the gplot legend, basically suppressing the gplot graph). You'll probably have some variable other than statecode to color the graphs by.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only played around with this for a few minutes - you can probably make some improvements! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data foo; set sashelp.us_data (where=(statecode in ('NC' 'SC' 'GA')));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;goptions xpixels=500 ypixels=500;&lt;BR /&gt;proc &lt;STRONG&gt;gmap&lt;/STRONG&gt; data=foo map=maps.us;&lt;BR /&gt;id statecode;&lt;BR /&gt;choro &lt;STRONG&gt;statecode&lt;/STRONG&gt; / discrete nolegend;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;symbol1 font='albany amt/unicode' value='25a0'x interpol=none h=.00001;&lt;BR /&gt;legend1 label=('My Legend') shape=symbol(.25in,.25in) repeat=1;&lt;BR /&gt;title; footnote;&lt;BR /&gt;goptions xpixels=600 ypixels=50;&lt;BR /&gt;proc gplot data=foo;&lt;BR /&gt;plot population_2010*population_2010=&lt;STRONG&gt;statecode&lt;/STRONG&gt; / legend=legend1&lt;BR /&gt;noaxes noframe;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="map_legend.png" style="width: 500px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57119iA62461042C7442F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="map_legend.png" alt="map_legend.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plot_legend.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57120i4C05638E865B0076/image-size/large?v=v2&amp;amp;px=999" role="button" title="plot_legend.png" alt="plot_legend.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 13:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732208#M21312</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2021-04-08T13:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Custom legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732220#M21314</link>
      <description>Thanks, Rob!  That did the trick/</description>
      <pubDate>Thu, 08 Apr 2021 13:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-Custom-legend/m-p/732220#M21314</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2021-04-08T13:29:43Z</dc:date>
    </item>
  </channel>
</rss>

