<?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: set row color by given RGB values in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748338#M92859</link>
    <description>&lt;P&gt;Thanks! These solutions are truely effective, and efficient!&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 00:33:00 GMT</pubDate>
    <dc:creator>PeimeiDa</dc:creator>
    <dc:date>2024-04-22T00:33:00Z</dc:date>
    <item>
      <title>set row color by given RGB values</title>
      <link>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748331#M92856</link>
      <description>&lt;P&gt;Hi, I'm trying to set row color (not cell color) by given RGB values in my columns. However, i can not get the correct loop for assigning the custom colors that I want. Could anyone help?&lt;/P&gt;
&lt;P&gt;Code and datatable attached. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Get the current data table
dt = Current Data Table();

// Initialize the color lists
RedList = Column(dt, "Red") &amp;lt;&amp;lt; Get Values;
GreenList = Column(dt, "Green") &amp;lt;&amp;lt; Get Values;
BlueList = Column(dt, "Blue") &amp;lt;&amp;lt; Get Values;

// Ensure we do not exceed the number of rows or the number of items in any color list
minLength = Min( N Rows(dt), N Items(RedList), N Items(GreenList), N Items(BlueList) );

// Loop to set the row colors
For( i = 1, i &amp;lt;= minLength, i++,
    // Clear any previous selections
    dt &amp;lt;&amp;lt; Clear Select;
    // Select the current row
    dt &amp;lt;&amp;lt; Select Where( Row() == i );
    // Set the row color
    dt &amp;lt;&amp;lt; Set Row Colors( RedList[i], GreenList[i], BlueList[i] );
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Apr 2024 17:00:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748331#M92856</guid>
      <dc:creator>PeimeiDa</dc:creator>
      <dc:date>2024-04-21T17:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: set row color by given RGB values</title>
      <link>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748336#M92857</link>
      <description>&lt;P&gt;This will be a bit slow due to all selections happening&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

dt &amp;lt;&amp;lt; show window(0);
For Each Row(dt,
	dt &amp;lt;&amp;lt; Clear Select;
	dt &amp;lt;&amp;lt; Select Rows(Row());
	dt &amp;lt;&amp;lt; Colors(RGB Color(Eval List({:Red, :Green, :Blue}) / 255));
);
dt &amp;lt;&amp;lt; show window(1);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if more speed is required it could be made faster by selection multiple rows (all rows which have specific color at the same time) or by setting row states.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

Summarize(dt, uniq = By(:Color), r = Min(:Red), g = Min(:Green), b = Min(:Blue));

For Each({cur_color, idx}, uniq,
	dt &amp;lt;&amp;lt; Select Where(:Color == cur_color);
	dt &amp;lt;&amp;lt; Colors(RGB Color(Eval List({r[idx], g[idx], b[idx]}) / 255));
	dt &amp;lt;&amp;lt; Clear Select;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1713725416561.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/63506iE4F758734554A68C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1713725416561.png" alt="jthi_0-1713725416561.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Nice picture!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;Just came to my mind that you could also use Summary table to set the colors&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

dt_summary = dt &amp;lt;&amp;lt; Summary(
	Group(:Color),
	Mean(:Red),
	Mean(:Green),
	Mean(:Blue),
	Freq("None"),
	Weight("None"),
	statistics column name format("column")
);

For Each Row(dt_summary,
	dt_summary &amp;lt;&amp;lt; Select Rows(Row());
	dt_summary &amp;lt;&amp;lt; Colors(RGB Color(Eval List({:Red, :Green, :Blue}) / 255));
	dt_summary &amp;lt;&amp;lt; Clear Select;
);
Close(dt_summary, no save);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit2: One more option looping over the whole table but without selections&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

For Each Row(dt,
	Row State(Row()) = Color State(Eval List({:Red, :Green, :Blue} / 255));
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I couldn't figure out how to convert Color State (for example Color State(-15527920)) to number (should be 512.925536155701) so I could have built row state matrix and use &amp;lt;&amp;lt; Set Row States.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 19:27:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748336#M92857</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-21T19:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: set row color by given RGB values</title>
      <link>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748337#M92858</link>
      <description>&lt;P&gt;2 things&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The syntax for setting the color of the row state color was incorrect.&lt;/LI&gt;
&lt;LI&gt;Using the Select Where() made the looping very slow.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Here is my modification&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Get the current data table
dt = Current Data Table();

// Initialize the color lists
RedList = Column(dt, "Red") &amp;lt;&amp;lt; Get Values;
GreenList = Column(dt, "Green") &amp;lt;&amp;lt; Get Values;
BlueList = Column(dt, "Blue") &amp;lt;&amp;lt; Get Values;

// Ensure we do not exceed the number of rows or the number of items in any color list
minLength = Min( N Rows(dt), N Items(RedList), N Items(GreenList), N Items(BlueList) );

// Loop to set the row colors
For( i = 1, i &amp;lt;= minLength, i++,
    // Clear any previous selections
    dt &amp;lt;&amp;lt; Clear Select;
    // Select the current row
    dt &amp;lt;&amp;lt; Select rows( i );
    // Set the row color
    dt &amp;lt;&amp;lt; Colors( rgb color(redlist[i],greenlist[i],bluelist[i]) );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Apr 2024 19:06:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748337#M92858</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-04-21T19:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: set row color by given RGB values</title>
      <link>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748338#M92859</link>
      <description>&lt;P&gt;Thanks! These solutions are truely effective, and efficient!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 00:33:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/748338#M92859</guid>
      <dc:creator>PeimeiDa</dc:creator>
      <dc:date>2024-04-22T00:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: set row color by given RGB values</title>
      <link>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/911345#M107074</link>
      <description>&lt;P&gt;Sorry to dredge up an older post, but I learned something about this just now after struggling for a bit. I was also trying to convert Color States to numbers without success. Instead, I found a way that's even faster as it avoids looping. It feels like cheating, but creating a formula column, then letting JMP use the built-in function to copy those row states was significantly faster than&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;'s previously very fast Edit2 version.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(dt &amp;lt;&amp;lt; new column ("Color", formula (color state (RGB color (:R, :G, :B))))) &amp;lt;&amp;lt; copy to row states;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Nov 2025 23:43:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-row-color-by-given-RGB-values/m-p/911345#M107074</guid>
      <dc:creator>Jed_Campbell</dc:creator>
      <dc:date>2025-11-04T23:43:17Z</dc:date>
    </item>
  </channel>
</rss>

