<?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 density plot - issues with line colour in rtf output in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973132#M25639</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;is absolutely correct. For the RTF style used by ODS RTF by default, the GraphFit and GraphFit2 colors are the same color -- differentiable only by the line pattern and thickness. When you overrode those attributes, the lines looked the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have two options:&lt;/P&gt;
&lt;P&gt;1) Use a different ODS style. The available styles will vary based on your SAS version.&lt;/P&gt;
&lt;P&gt;2) Change your macro to set GraphDataN ("N" replaced by your loop index) on each of your density plots. For example, iineattrs=GraphData1(pattern=solid thickness=2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Fri, 22 Aug 2025 16:43:20 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2025-08-22T16:43:20Z</dc:date>
    <item>
      <title>SGPlot density plot - issues with line colour in rtf output</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973107#M25636</link>
      <description>&lt;P&gt;I am currently having a nightmare with some kernel density plots I am trying to produce. For some reason in the plots where I am plotting two kernel density lines, despite showing correctly in the SAS output window, the RTF file I am creating show both lines as the same colour. I do not have the same issue in the plots with 3 or more kernel density plots overlaid. These are showing fine as different colours in both the SAS output window and the output RTF file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=graph CYCLEATTRS;&lt;BR /&gt;%do r=1 %to &amp;amp;n;&lt;BR /&gt;density &amp;amp;endpoint&amp;amp;r / type=kernel freq=frequency name="&amp;amp;r" legendlabel="&amp;amp;&amp;amp;class&amp;amp;r (n=&amp;amp;&amp;amp;count&amp;amp;r)" lineattrs=(pattern=solid thickness=2);&lt;BR /&gt;%end;&lt;BR /&gt;keylegend /&lt;BR /&gt;valueattrs=(Size=7);&lt;BR /&gt;yaxis label='Density';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2025 12:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973107#M25636</guid>
      <dc:creator>SamR</dc:creator>
      <dc:date>2025-08-22T12:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot density plot - issues with line colour in rtf output</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973130#M25637</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/476989"&gt;@SamR&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is interesting. I have reproduced the issue and found a difference in the GTL (Graph Template Language) code created by adding the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p073bl97jzadkmn15lhq58yiy2uh.htm#n086387n9y3ct3n1i9djru01fomy" target="_blank" rel="noopener"&gt;TMPLOUT= option&lt;/A&gt; to the PROC SGPLOT statement: With only two density curves the corresponding &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/n1nh9dhh759jrvn124sn8nn78fv5.htm" target="_blank" rel="noopener"&gt;DensityPlot statements&lt;/A&gt; use the following &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/n1nh9dhh759jrvn124sn8nn78fv5.htm#p1c50mysekvm3zn1dt0lgvp1vg0c" target="_blank" rel="noopener"&gt;LINEATTRS= options&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;Lineattrs=&lt;STRONG&gt;GraphFit&lt;/STRONG&gt;( Pattern=1 Thickness=2)
Lineattrs=&lt;STRONG&gt;GraphFit2&lt;/STRONG&gt;( Pattern=1 Thickness=2)&lt;/PRE&gt;
&lt;P&gt;By adding a third density curve the GraphFit style elements are replaced by GraphData style elements:&lt;/P&gt;
&lt;PRE&gt;Lineattrs=&lt;STRONG&gt;GraphData1&lt;/STRONG&gt;( Pattern=1 Thickness=2)
Lineattrs=&lt;STRONG&gt;GraphData2&lt;/STRONG&gt;( Pattern=1 Thickness=2)
Lineattrs=&lt;STRONG&gt;GraphData3&lt;/STRONG&gt;( Pattern=1 Thickness=2)&lt;/PRE&gt;
&lt;P&gt;Which makes sense because there are about 15 GraphData style elements, but only two GraphFit style elements. Apparently, GraphData work better with your line pattern and thickness specifications.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I suggest that you enforce the use of GraphData by adding that to your existing &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18r9s9vxpuewqn0zeo8p1oekbmn.htm#n03m68wfbalouen16rh0k03anud6" target="_blank" rel="noopener"&gt;LINEATTRS= option&lt;/A&gt; of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18r9s9vxpuewqn0zeo8p1oekbmn.htm" target="_blank" rel="noopener"&gt;DENSITY statement&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#999999"&gt;... lineattrs=&lt;/FONT&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;GraphData&amp;amp;r&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#999999"&gt;(pattern=solid thickness=2);&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Does this work in your environment?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2025 15:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973130#M25637</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-08-22T15:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot density plot - issues with line colour in rtf output</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973131#M25638</link>
      <description>&lt;P&gt;Yes, what you report is true. It has to do with the RTF style being different than modern styles such as the HTML styles. What happens is&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;When there are two curves, the plot uses the GRAPHFIT and GRAPHFIT2 attributes for the curves.&lt;/LI&gt;
&lt;LI&gt;In an HTML style,&amp;nbsp;GRAPHFIT and GRAPHFIT2 have different colors. But in the RTF style, the colors are similar, but one curve is drawn by using a dashed line. Since you have explicitly set PATTERN=SOLID, the two curves look the same in RTF.&lt;/LI&gt;
&lt;LI&gt;When there are more than two curves, the procedure uses the GRAPHDATA1,&amp;nbsp;GRAPHDATA2, etc, attributes, which give the curves different colors.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;There are two workaround. You&amp;nbsp;could delete the PATTERN=SOLID option, but I am assuming you don't want to do this. The second workaround is to modify your macro loop to explicitly use the GRAPHDATA family of attributes, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=graph CYCLEATTRS;
%do r=1 %to &amp;amp;n;
density &amp;amp;endpoint&amp;amp;r / type=kernel freq=frequency name="&amp;amp;r" legendlabel="&amp;amp;&amp;amp;class&amp;amp;r (n=&amp;amp;&amp;amp;count&amp;amp;r)" 
        lineattrs=GraphData&amp;amp;r.(pattern=solid thickness=2);
%end;
keylegend /
valueattrs=(Size=7);
yaxis label='Density';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Aug 2025 15:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973131#M25638</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-08-22T15:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot density plot - issues with line colour in rtf output</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973132#M25639</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;is absolutely correct. For the RTF style used by ODS RTF by default, the GraphFit and GraphFit2 colors are the same color -- differentiable only by the line pattern and thickness. When you overrode those attributes, the lines looked the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have two options:&lt;/P&gt;
&lt;P&gt;1) Use a different ODS style. The available styles will vary based on your SAS version.&lt;/P&gt;
&lt;P&gt;2) Change your macro to set GraphDataN ("N" replaced by your loop index) on each of your density plots. For example, iineattrs=GraphData1(pattern=solid thickness=2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2025 16:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973132#M25639</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2025-08-22T16:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: SGPlot density plot - issues with line colour in rtf output</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973268#M25640</link>
      <description>&lt;P&gt;Thank you so much for the responses. Added in&amp;nbsp;lineattrs=GraphData&amp;amp;r. works!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Aug 2025 08:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPlot-density-plot-issues-with-line-colour-in-rtf-output/m-p/973268#M25640</guid>
      <dc:creator>SamR</dc:creator>
      <dc:date>2025-08-26T08:26:29Z</dc:date>
    </item>
  </channel>
</rss>

