<?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 can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920309#M24469</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to produce a graph comparing time-to-failure between two groups within yearly cohorts over a 20-year period. That's necessarily a lot of data. I will be presenting these data in other ways, but to begin, I must present them as a whole.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The attached graph shows two groups for each yearly cohort but it is difficult to distinguish between the group A (left) and group B (right). I have attempted to do this by adding a gradient and transparency, but perhaps there is a better way. Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, at present there is no way to distinguish between Group A (left) and Group B (right) aside from the footnote. Is there a way for me to somehow label the left (solid) vs. right (hatched) groups other than doubling the list of values in the legend? For example, a supplementary legend in the top-right corner that states: Solid = Group A / Hatched = Group B?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe I shouldn't be using VBAR for this type of graph? If so, what other graph option would work better?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your time!&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-center" image-alt="FigureZ.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94627i5F4DEA68330B5A19/image-size/large?v=v2&amp;amp;px=999" role="button" title="FigureZ.png" alt="FigureZ.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics / reset 
		height=6.5in imagename="FigureZ" imagefmt=PNG ATTRPRIORITY=NONE;
	Footnote justify=left height=1.2 font="Times New Roman" "Figure X.XX. Time-to-Failure Rates - Group A (Left) vs. Group B (Right)";
	Title;
 
	proc sgplot data=Failure noborder nocycleattrs;

	vbar Cohort/ 
		response=GroupA
		group=TTF
		grouporder=ascending
		groupdisplay=stack
		barwidth=0.4
		name="GroupA"
		legendlabel="GroupA"
		discreteoffset=-0.4;

	vbar Cohort/ 
		response=GroupB
		group=TTF
		grouporder=ascending
		groupdisplay=stack
		barwidth=0.4
		name="GroupB"
		legendlabel="GroupB"
		fillattrs=(transparency=0.9)
		filltype=gradient
		fillpattern
			fillpatternattrs=(pattern=x4);

	keylegend "GroupA"
		/ title="Time-to-Failure (Years)" Titleattrs=(size=12) Valueattrs=(size=12) location=outside position=bottom noborder;

	xaxis  Valueattrs=(size=12) discreteorder=data display=(nolabel noticks);
	yaxis Valueattrs=(size=12) Labelattrs=(size=12) grid values=(0 to 75 by 5) label="Failure Rate of Cohort (Percent)";
	run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Mar 2024 16:20:00 GMT</pubDate>
    <dc:creator>samp945</dc:creator>
    <dc:date>2024-03-14T16:20:00Z</dc:date>
    <item>
      <title>How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920309#M24469</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to produce a graph comparing time-to-failure between two groups within yearly cohorts over a 20-year period. That's necessarily a lot of data. I will be presenting these data in other ways, but to begin, I must present them as a whole.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The attached graph shows two groups for each yearly cohort but it is difficult to distinguish between the group A (left) and group B (right). I have attempted to do this by adding a gradient and transparency, but perhaps there is a better way. Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, at present there is no way to distinguish between Group A (left) and Group B (right) aside from the footnote. Is there a way for me to somehow label the left (solid) vs. right (hatched) groups other than doubling the list of values in the legend? For example, a supplementary legend in the top-right corner that states: Solid = Group A / Hatched = Group B?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe I shouldn't be using VBAR for this type of graph? If so, what other graph option would work better?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your time!&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-center" image-alt="FigureZ.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94627i5F4DEA68330B5A19/image-size/large?v=v2&amp;amp;px=999" role="button" title="FigureZ.png" alt="FigureZ.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics / reset 
		height=6.5in imagename="FigureZ" imagefmt=PNG ATTRPRIORITY=NONE;
	Footnote justify=left height=1.2 font="Times New Roman" "Figure X.XX. Time-to-Failure Rates - Group A (Left) vs. Group B (Right)";
	Title;
 
	proc sgplot data=Failure noborder nocycleattrs;

	vbar Cohort/ 
		response=GroupA
		group=TTF
		grouporder=ascending
		groupdisplay=stack
		barwidth=0.4
		name="GroupA"
		legendlabel="GroupA"
		discreteoffset=-0.4;

	vbar Cohort/ 
		response=GroupB
		group=TTF
		grouporder=ascending
		groupdisplay=stack
		barwidth=0.4
		name="GroupB"
		legendlabel="GroupB"
		fillattrs=(transparency=0.9)
		filltype=gradient
		fillpattern
			fillpatternattrs=(pattern=x4);

	keylegend "GroupA"
		/ title="Time-to-Failure (Years)" Titleattrs=(size=12) Valueattrs=(size=12) location=outside position=bottom noborder;

	xaxis  Valueattrs=(size=12) discreteorder=data display=(nolabel noticks);
	yaxis Valueattrs=(size=12) Labelattrs=(size=12) grid values=(0 to 75 by 5) label="Failure Rate of Cohort (Percent)";
	run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Mar 2024 16:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920309#M24469</guid>
      <dc:creator>samp945</dc:creator>
      <dc:date>2024-03-14T16:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920315#M24470</link>
      <description>&lt;P&gt;Maybe something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Failure2;
  set Failure;
  GroupB  = - GroupB;
run;


ods graphics / reset 
		height=6.5in imagename="FigureZ" imagefmt=PNG ATTRPRIORITY=NONE;
	Footnote justify=left height=1.2 font="Times New Roman" "Figure X.XX. Time-to-Failure Rates - Group A (Left) vs. Group B (Right)";
	Title;
 
	proc sgplot data=Failure2 noborder nocycleattrs;

	vbar Cohort/ 
		response=GroupA
		group=TTF
		grouporder=ascending
		groupdisplay=stack
		barwidth=0.7
		name="GroupA"
		legendlabel="GroupA"
		discreteoffset=-0.1
    ;

	vbar Cohort/ 
		response=GroupB
		group=TTF
		grouporder=ascending
		groupdisplay=stack
		barwidth=0.7
		name="GroupB"
		legendlabel="GroupB"
		fillattrs=(transparency=0.9)
		filltype=gradient
		fillpattern
			fillpatternattrs=(pattern=x4);

	keylegend "GroupA"
		/ title="Time-to-Failure (Years)" Titleattrs=(size=12) Valueattrs=(size=12) location=outside position=bottom noborder;

	xaxis  Valueattrs=(size=12) discreteorder=data display=(nolabel noticks);
	yaxis Valueattrs=(size=12) Labelattrs=(size=12) grid 
    values=(-60 to 60 by 5) 
    valuesdisplay=(
    %macro loop(s,e,b,f=ABS);
      %local i;
      %do i = &amp;amp;s. %to &amp;amp;e. %by &amp;amp;b.;
        "%sysfunc(&amp;amp;f.(&amp;amp;i.))"
      %end;
    %mend;
    %loop(-60,60,5)
    )  

    label="Failure Rate of Cohort (Percent)";
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I had to generate data myself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Failure;
  call streaminit(123);
  retain GroupA GroupB 10; 
  do Cohort = 2010 to 2020;

    do TTF = 1,2,3,4,5,6;
      GroupA + (-rand("uniform",0,.25));
      GroupB + (-rand("uniform",0,.25));
      output;
    end;

  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1710435320405.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94628i4A8EDFDA5843C9AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1710435320405.png" alt="yabwon_0-1710435320405.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;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 16:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920315#M24470</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-14T16:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920341#M24471</link>
      <description>&lt;P&gt;One alternative would be to transpose your data so that your GroupA and GroupB responses are folded together with a GROUP column containing the values "GroupA" and "GroupB". Then, you could something like the following with PROC SGPANEL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgpanel data=sashelp.prdsale;
panelby year / layout=rowlattice novarname;
vbar month / response=actual group=product;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPanel.png" style="width: 480px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94632iBE15851A1CBF9D27/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPanel.png" alt="SGPanel.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 20:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920341#M24471</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2024-03-14T20:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920356#M24472</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt; for your suggestions!&lt;BR /&gt;&lt;BR /&gt;However, I am hoping to find a strategy that plots each group side-by-side so that each yearly cohort can be compared without referring to any values on the Y-axis.&lt;BR /&gt;&lt;BR /&gt;For example, my existing vbar plots show that for cohorts 2000 - 2004, group A (left) had a higher Time-to-Failure than group B (right), but this trend reversed for cohorts 2005 onward (group B had a higher TTF) than group A).&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 23:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920356#M24472</guid>
      <dc:creator>samp945</dc:creator>
      <dc:date>2024-03-14T23:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920357#M24473</link>
      <description>&lt;P&gt;Given that goal, I would use a two overlaid VLINEs instead of overlayed VBARs, and I would drop the TTF group. That way, you can clearly see the transition you described. Just use the default STAT of SUM. I would also use the MARKERS option so you will see the markers at each year.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 01:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920357#M24473</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2024-03-15T01:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920360#M24475</link>
      <description>&lt;P&gt;I would like to use Medal Graph:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2014/02/12/sochi-medal-graphs/" target="_blank" rel="noopener"&gt;Sochi Medal Graphs - Graphically Speaking (sas.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
https://blogs.sas.com/content/graphicallyspeaking/2014/02/12/sochi-medal-graphs/
*/
data Failure;
  call streaminit(123);
  retain GroupA GroupB 10; 
  do Cohort = 2010 to 2020;

    do TTF = 1,2,3,4,5,6;
      GroupA + (-rand("uniform",0,.25));
      GroupB + (-rand("uniform",0,.25));
      output;
    end;

  end;
run;

proc sgpanel data=Failure noautolegend;
  panelby TTF / layout=panel rows=1 onepanel sort=data  spacing=5;
  hbar Cohort / response=GroupA  nostatlabel transparency=0.5 name='a';
  hbar Cohort / response=GroupB  nostatlabel transparency=0.5 barwidth=0.4 name='b';
  keylegend 'a' 'b';
  rowaxis discreteorder=data display=(nolabel) fitpolicy=none;
  colaxis integer display=(nolabel);
  run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1710478214552.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94636i1EB2B3DD6773A68D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1710478214552.png" alt="Ksharp_0-1710478214552.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 04:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920360#M24475</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-03-15T04:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920421#M24476</link>
      <description>&lt;P&gt;I generally hate stacked bar charts.&amp;nbsp; It's really hard to see trends in the size of each section of a bar, unless the differences are huge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it would help to think about "what is the purpose of this plot" or, "what is the story I want this graph to tell."&amp;nbsp; It's often easier for a graph to tell one story clearly, rather than try to make it tell multiple stories.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with Dan, if your goal is to compare failure rates, I would use a line plot.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I think time-to-failure, I think Kaplan-Meier survival plot.&amp;nbsp; What if you made a paneled survival plot?&amp;nbsp; Each plot could show the survival curve for your two groups.&amp;nbsp; And there could be one plot per year.&amp;nbsp; I guess 20 plots in a panel might be a bit much...&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 13:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920421#M24476</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-03-15T13:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I simplify/beautify a busy stacked bar chart comparing two groups within yearly cohorts?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920466#M24477</link>
      <description>&lt;P&gt;Since the segments starting position don't always align, this graph doesn't really do that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd consider some variation on a slope graph with small multiples possibly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Slope Graph&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.storytellingwithdata.com/blog/2020/7/27/what-is-a-slopegraph" target="_blank"&gt;https://www.storytellingwithdata.com/blog/2020/7/27/what-is-a-slopegraph&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Small Multiples&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.juiceanalytics.com/writing/better-know-visualization-small-multiples" target="_blank"&gt;https://kieranhealy.org/blog/archives/2020/03/27/a-covid-small-multiple/&lt;/A&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, 15 Mar 2024 14:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-can-I-simplify-beautify-a-busy-stacked-bar-chart-comparing/m-p/920466#M24477</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-03-15T14:57:09Z</dc:date>
    </item>
  </channel>
</rss>

