<?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 how to set a global legend for several subplots within one contour plot in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294789#M10380</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to draw a contour plot with contourplotparm. The plot contains 4 cells and each cell shares the same x- and y- values but different z- values. Now here's the problem: I want to&amp;nbsp;make all the cells share one legend, i.e.&amp;nbsp;a same contour color in all 4 cells relates to a same z- value. Such as in the following example, I'd like to make z=0.0012 always related to&amp;nbsp;orange across all the cells no matter z is density1 or density2 etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data gridded;&lt;BR /&gt;set sashelp.gridded;&lt;BR /&gt;density1=density*1.2;&lt;BR /&gt;density2=density*1.5;&lt;BR /&gt;density3=density*1.8;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc template;&lt;BR /&gt;define statgraph contourplotparm;&lt;BR /&gt;begingraph;&lt;BR /&gt;LAYOUT LATTICE / COLUMNS=2 ROWS=2 ;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour1" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour1"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density1 /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour2" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour2"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density2 /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour3" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour3"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density3 /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour4" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour4"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;endlayout;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sgrender data=gridded template=contourplotparm;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help? Thanks!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tingting&lt;/P&gt;</description>
    <pubDate>Mon, 29 Aug 2016 13:20:29 GMT</pubDate>
    <dc:creator>ttmei</dc:creator>
    <dc:date>2016-08-29T13:20:29Z</dc:date>
    <item>
      <title>how to set a global legend for several subplots within one contour plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294789#M10380</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to draw a contour plot with contourplotparm. The plot contains 4 cells and each cell shares the same x- and y- values but different z- values. Now here's the problem: I want to&amp;nbsp;make all the cells share one legend, i.e.&amp;nbsp;a same contour color in all 4 cells relates to a same z- value. Such as in the following example, I'd like to make z=0.0012 always related to&amp;nbsp;orange across all the cells no matter z is density1 or density2 etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data gridded;&lt;BR /&gt;set sashelp.gridded;&lt;BR /&gt;density1=density*1.2;&lt;BR /&gt;density2=density*1.5;&lt;BR /&gt;density3=density*1.8;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc template;&lt;BR /&gt;define statgraph contourplotparm;&lt;BR /&gt;begingraph;&lt;BR /&gt;LAYOUT LATTICE / COLUMNS=2 ROWS=2 ;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour1" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour1"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density1 /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour2" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour2"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density2 /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour3" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour3"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;layout overlay;&lt;BR /&gt;contourplotparm x=height y=weight z=density3 /&lt;BR /&gt;contourtype=fill nhint=12&lt;BR /&gt;name="Contour4" colormodel=threecolorramp;&lt;BR /&gt;continuouslegend "Contour4"/ title="K";&lt;BR /&gt;endlayout;&lt;BR /&gt;endlayout;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sgrender data=gridded template=contourplotparm;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help? Thanks!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tingting&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 13:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294789#M10380</guid>
      <dc:creator>ttmei</dc:creator>
      <dc:date>2016-08-29T13:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: color related with specific numeric in colormodel= option and a global legend used for all cells</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294791#M10381</link>
      <description>&lt;P&gt;What version of SAS are you using?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 13:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294791#M10381</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2016-08-29T13:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: color related with specific numeric in colormodel= option and a global legend used for all cells</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294792#M10382</link>
      <description>&lt;P&gt;Hello, thank you. I use sas9.4&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 13:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294792#M10382</guid>
      <dc:creator>ttmei</dc:creator>
      <dc:date>2016-08-29T13:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to set a global legend for several subplots within one contour plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294800#M10383</link>
      <description>&lt;P&gt;I often find that it is helpful to add a fake observation that contains the minimum and maximum value of the response variables. This forces the color model to use the same scales.&amp;nbsp; For your example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Fake;
height=.; weight=.;
/* set lower bound for response vars */
density1=0; density2=0; density3=0;  output;
/* set upper bound for response vars */
density1=0.0035; density2=0.0035; density3=0.0035;  output;
run;

data All;
set Fake gridded;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use the "All" data set in your analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For other ways that prepending fake data can help with graphics, see this &lt;A href="http://blogs.sas.com/content/iml/2016/02/17/include-and-order-categories-in-legends.html" target="_self"&gt;article on prepending fake data.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 13:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294800#M10383</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-29T13:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to set a global legend for several subplots within one contour plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294805#M10384</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It sounds a brilliant&amp;nbsp;idea, I'll try it. It should work. Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tingting&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 13:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294805#M10384</guid>
      <dc:creator>ttmei</dc:creator>
      <dc:date>2016-08-29T13:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to set a global legend for several subplots within one contour plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294817#M10385</link>
      <description>&lt;P&gt;A RANGEATTRMAP is probably the best solution for you. You will want to replace literal values for the "min" and "max" keywords below; otherwise, you ranges will not be consistent across all contours. Give the code below a try and see if it works for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc template;
define statgraph contourplotparm;
begingraph;
rangeattrmap name="zcolor";
    range min-&amp;lt;5  / rangecolormodel=(threecolorramp:startcolor threecolorramp:neutralcolor);
    range 5-5 / rangecolor=orange;
    range 5&amp;lt;-max / rangecolormodel=( threecolorramp:neutralcolor threecolorramp:endcolor);
  endrangeattrmap;
 
 rangeattrvar attrvar=zdensity var=density attrmap="zcolor";
 rangeattrvar attrvar=zdensity1 var=density1 attrmap="zcolor";
 rangeattrvar attrvar=zdensity2 var=density2 attrmap="zcolor";
 rangeattrvar attrvar=zdensity3 var=density3 attrmap="zcolor";

LAYOUT LATTICE / COLUMNS=2 ROWS=2 ;
layout overlay;
contourplotparm x=height y=weight z=zdensity /
contourtype=fill nhint=12
name="Contour1" colormodel=threecolorramp;
continuouslegend "Contour1"/ title="K";
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity1 /
contourtype=fill nhint=12
name="Contour2" colormodel=threecolorramp;
continuouslegend "Contour2"/ title="K";
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity2 /
contourtype=fill nhint=12
name="Contour3" colormodel=threecolorramp;
continuouslegend "Contour3"/ title="K";
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity3 /
contourtype=fill nhint=12
name="Contour4" colormodel=threecolorramp;
continuouslegend "Contour4"/ title="K";
endlayout;
endlayout;
endgraph;
end;
run;
ods listing style=toto ;
proc sgrender data=gridded template=contourplotparm;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Aug 2016 13:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294817#M10385</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2016-08-29T13:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to set a global legend for several subplots within one contour plot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294821#M10386</link>
      <description>&lt;P&gt;One more change...&lt;/P&gt;
&lt;P&gt;You wanted one legend for all contours. Now that you are using the rangeattrmap, you can assign the legend to just one plot. See the revised code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
define statgraph contourplotparm;
begingraph;
rangeattrmap name="zcolor";
    range min-&amp;lt;5  / rangecolormodel=(threecolorramp:startcolor threecolorramp:neutralcolor);
    range 5-5 / rangecolor=orange;
    range 5&amp;lt;-max / rangecolormodel=( threecolorramp:neutralcolor threecolorramp:endcolor);
  endrangeattrmap;
 
 rangeattrvar attrvar=zdensity var=density attrmap="zcolor";
 rangeattrvar attrvar=zdensity1 var=density1 attrmap="zcolor";
 rangeattrvar attrvar=zdensity2 var=density2 attrmap="zcolor";
 rangeattrvar attrvar=zdensity3 var=density3 attrmap="zcolor";

LAYOUT LATTICE / COLUMNS=2 ROWS=2 ;
layout overlay;
contourplotparm x=height y=weight z=zdensity /
contourtype=fill nhint=12
name="Contour1" colormodel=threecolorramp;
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity1 /
contourtype=fill nhint=12
name="Contour2" colormodel=threecolorramp;
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity2 /
contourtype=fill nhint=12
name="Contour3" colormodel=threecolorramp;
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity3 /
contourtype=fill nhint=12
name="Contour4" colormodel=threecolorramp;
endlayout;
sidebar / align=bottom;
continuouslegend "Contour4"/ title="K";
endsidebar;
endlayout;
endgraph;
end;
run;
ods listing style=toto ;
proc sgrender data=gridded template=contourplotparm;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 14:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-a-global-legend-for-several-subplots-within-one/m-p/294821#M10386</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2016-08-29T14:16:46Z</dc:date>
    </item>
  </channel>
</rss>

