<?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: Sgplot - invert legend order so it matches stacked vbar order in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/901514#M24177</link>
    <description>&lt;P&gt;The REVERSEAUTO option on the KEYLEGEND should get you what you want. Here is a simple example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.cars;
vbar origin / response=msrp group=type name="type";
keylegend "type" / sortorder=reverseauto position=right;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 04 Nov 2023 00:29:18 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2023-11-04T00:29:18Z</dc:date>
    <item>
      <title>Sgplot - invert legend order so it matches stacked vbar order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/901512#M24176</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying and searched all around the internet how to code this, I am pretty sure it is simple but i am going in&amp;nbsp; circles and hope that someone here can help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;notably i tried to follow the advice here, unsuccessfully &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2016/02/04/legend-order/" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/graphicallyspeaking/2016/02/04/legend-order/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to invert the order of the legend of the attached plot so it matches that of the bars - as you can see for now you have in the plot the legend starts with Staphylococcus aureus on top, when in the plot it is at the bottom. It would be much more readable if the order of the legend matched that of the plot&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ods html image_dpi=300;
title Frequency of pathogens by location of onset;
proc sgplot data=klfig.path;
vbar location / response=Percent group=Pathogen groupdisplay=stack SEGLABELFORMAT=percent10.1 seglabel grouporder=reversedata;
xaxis discreteorder=data;
yaxis grid values=(0 to 1 by 0.1) label="Percentage of each Pathogen" discreteorder=data;
 keylegend / location=outside  position=right across=1 title="order needs inverted";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Pathogens.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89401i913C31610F4376BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Pathogens.png" alt="Pathogens.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 23:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/901512#M24176</guid>
      <dc:creator>AlexisT1</dc:creator>
      <dc:date>2023-11-03T23:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot - invert legend order so it matches stacked vbar order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/901514#M24177</link>
      <description>&lt;P&gt;The REVERSEAUTO option on the KEYLEGEND should get you what you want. Here is a simple example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.cars;
vbar origin / response=msrp group=type name="type";
keylegend "type" / sortorder=reverseauto position=right;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Nov 2023 00:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/901514#M24177</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2023-11-04T00:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot - invert legend order so it matches stacked vbar order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/901517#M24178</link>
      <description>&lt;P&gt;thank you very much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 01:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/901517#M24178</guid>
      <dc:creator>AlexisT1</dc:creator>
      <dc:date>2023-11-04T01:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot - invert legend order so it matches stacked vbar order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/906157#M24219</link>
      <description>&lt;P&gt;Glad you asked this question - sorting the legend like this should be a "best practice" imho.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 00:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-invert-legend-order-so-it-matches-stacked-vbar-order/m-p/906157#M24219</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2023-12-05T00:44:01Z</dc:date>
    </item>
  </channel>
</rss>

