<?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: How to change the color of curves based on condition on the data in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45865#M26151</link>
    <description>&lt;P&gt;A good technique is to make a small graph like you want, save the script, and then use that script as a pattern to make an automated graph, possibly with more variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So start with&amp;nbsp;@ih's graph and customize the legend interactively to change the line styles and item names. Save the script for that graphs to use as a template for a more elaborate one. You'll be writing&amp;nbsp;a script that writes another script and then runs it.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2017 21:17:28 GMT</pubDate>
    <dc:creator>XanGregg</dc:creator>
    <dc:date>2017-10-12T21:17:28Z</dc:date>
    <item>
      <title>How to change the color of curves based on condition on the data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45823#M26142</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to color curves in a specific way and I do not find a way...&lt;/P&gt;&lt;P&gt;Basically, I have a couple of curves that are grouped by a label. How can I display all the curves with a different color for each group ?&lt;/P&gt;&lt;P&gt;So far, I tried in Graph Builder putting the "label" put in the "overlay" part...But like that JMP considers all the curves of a group like being ONE curve.&lt;/P&gt;&lt;P&gt;I tried a more advanced thing using JSL (find the code below). I was able to generate the curves and access the different lines and color them independently, but I lose the link between the lines and the label.&lt;/P&gt;&lt;P&gt;In the example below: how can I get all the curves of Honda in red, those of Ford in Blue, and those of GM in purple ? (this assuming of course that I do not know a priori how many curves are in each group, and not how many groups there are).&lt;/P&gt;&lt;P&gt;Any ideas ?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Generate a simple table as example
dt = New Table( "Untitled 9050",
	Add Rows( 33 ),
	New Column( "Time [years]",
		Numeric,
		Continuous,
		Format( "Best", 2 ),
		Set Values(
			[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0,
			1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
		)
	),
	New Column( "car1",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Values(
			[0, 0.8, 1.6, 2.4, 3.2, 4, 4.8, 5.6, 6.4, 7.2, 8, 0, 1.2, 2.4, 3.6, 4.8,
			6, 7.2, 8.4, 9.6, 10.8, 12, 0, 2.2, 4.4, 6.6, 8.8, 11, 13.2, 15.4, 17.6,
			19.8, 22]
		)
	),
	New Column( "car2",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Selected,
		Set Values(
			[0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 0, 1.4, 2.8, 4.2, 5.6, 7,
			8.4, 9.8, 11.2, 12.6, 14, 0, 2.4, 4.8, 7.2, 9.6, 12, 14.4, 16.8, 19.2,
			21.6, 24]
		)
	),
	New Column( "car3",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Values(
			[0, 0.6, 1.2, 1.8, 2.4, 3, 3.6, 4.2, 4.8, 5.4, 6, 0, 1.6, 3.2, 4.8, 6.4,
			8, 9.6, 11.2, 12.8, 14.4, 16, 0, 2.6, 5.2, 7.8, 10.4, 13, 15.6, 18.2,
			20.8, 23.4, 26]
		)
	),
	New Column( "car4",
		Numeric,
		Continuous,
		Format( "Best", 12 ),
		Set Values(
			[0, 0.4, 0.8, 1.2, 1.6, 2, 2.4, 2.8, 3.2, 3.6, 4, 0, 1.8, 3.6, 5.4, 7.2,
			9, 10.8, 12.6, 14.4, 16.2, 18, 0, 2.8, 5.6, 8.4, 11.2, 14, 16.8, 19.6,
			22.4, 25.2, 28]
		)
	),
	New Column( "Manufacturer",
		Character( 16 ),
		Nominal,
		Set Values(
			{"Honda", "Honda", "Honda", "Honda", "Honda", "Honda", "Honda", "Honda",
			"Honda", "Honda", "Honda", "Ford", "Ford", "Ford", "Ford", "Ford",
			"Ford", "Ford", "Ford", "Ford", "Ford", "Ford", "GM", "GM", "GM", "GM",
			"GM", "GM", "GM", "GM", "GM", "GM", "GM"}
		)
	)
);

// stack the table
dt_Stack = dt &amp;lt;&amp;lt; Stack(
	columns( :car1, :car2, :car3, :car4 ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);

// Create a graph
MyGraph = Graph Builder(
	Variables( X( :Name( "Time [years]" ) ), Y( :Data ), Overlay( :Label ) ),
	Elements(
		Points( X, Y, Legend( 1 ), Jitter( 1 ) ),
		Smoother( X, Y, Legend( 2 ) )
	)
);

// Access the lines and their properties
GraphsRep = Report( MyGraph );
nbp = GraphsRep[FrameBox( 1 )] &amp;lt;&amp;lt; segCount( "LineSeg" );
// Modify the lines colors
For( n = 1, n &amp;lt;= nbp, n++,
	s = GraphsRep[FrameBox( 1 )] &amp;lt;&amp;lt; FindSeg( LineSeg( n ) );
	s &amp;lt;&amp;lt; Line Color( "Black" );
			);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Oct 2017 18:04:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45823#M26142</guid>
      <dc:creator>samir</dc:creator>
      <dc:date>2017-10-12T18:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the color of curves based on condition on the data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45834#M26143</link>
      <description>&lt;P&gt;Are you looking for a separate curve or line for each car? If so, using your unpivoted data table, you could display all four cars on the y axis and then overlay manufacturer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Size( 528, 454 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Name( "Time [years]" ) ),
		Y( :car1 ),
		Y( :car2, Position( 1 ) ),
		Y( :car3, Position( 1 ) ),
		Y( :car4, Position( 1 ) ),
		Overlay( :Manufacturer )
	),
	Elements( Line( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 7 ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Oct 2017 18:27:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45834#M26143</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2017-10-12T18:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the color of curves based on condition on the data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45847#M26144</link>
      <description>&lt;P&gt;That is pretty much what I wanted to do, except that in your solution, I need to know upfront how many "cars" are available and put them manually: suppose I have 2000 cars and not 4 as in the example :(&lt;/img&gt;&lt;/P&gt;&lt;P&gt;besides, what if I do not want a different line style per car ?&lt;/P&gt;&lt;P&gt;And if I just want a legend that mentions the manufacturer and not the manufacturer + car ? (to simplify the legend).&lt;/P&gt;&lt;P&gt;All in all, your solution is definitely interesting, but I need more control and automation.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 19:01:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45847#M26144</guid>
      <dc:creator>samir</dc:creator>
      <dc:date>2017-10-12T19:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the color of curves based on condition on the data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45865#M26151</link>
      <description>&lt;P&gt;A good technique is to make a small graph like you want, save the script, and then use that script as a pattern to make an automated graph, possibly with more variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So start with&amp;nbsp;@ih's graph and customize the legend interactively to change the line styles and item names. Save the script for that graphs to use as a template for a more elaborate one. You'll be writing&amp;nbsp;a script that writes another script and then runs it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 21:17:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45865#M26151</guid>
      <dc:creator>XanGregg</dc:creator>
      <dc:date>2017-10-12T21:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the color of curves based on condition on the data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45870#M26155</link>
      <description>&lt;P&gt;Four points:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Scripting&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/494"&gt;@XanGregg&lt;/a&gt; is probably right that what you really want is some group of plots created or modified using JSL instead of one big chart. Below are two things to try though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Plotting Lines&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am having a hard time&amp;nbsp;picturing the graph you want to create, it sounds like a lot of lines on one chart and a page-long legend. Using the pivoted data, the top chart in the script below creates lines for each car colored by manufacturer.&amp;nbsp;&amp;nbsp;With only 5 lines styles to work with you can not be&amp;nbsp;identify the car type in the legend using anything but color.&amp;nbsp; Maybe you could use this chart to identify the manufacturer of the car and then a second chart&amp;nbsp;that is&amp;nbsp;grouped or&amp;nbsp;wrapped by manufacture and then colored by car? That is the bottom chart in this script, note you can click on a line and see it identified in the bottom chart.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Start with the long table in your first post.&lt;BR /&gt;New Window("Two Graphs",
Graph Builder(
	Size( 600, 400 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Name( "Time [years]" ) ),
		Y( :Data ),
		Overlay( :Name( "Man-Car" ) ),
		Color( :Manufacturer )
	),
	Elements( Line( X, Y, Legend( 20 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Time [years]",
			ScaleBox,
			{Label Row( Show Major Grid( 1 ) )}
		),
		Dispatch( {}, "Data", ScaleBox, {Label Row( Show Major Grid( 1 ) )} )
	)
),
Graph Builder(
	Size( 604, 448 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Name( "Time [years]" ) ),
		Y( :Data ),
		Wrap( :Manufacturer ),
		Overlay( :Label )
	),
	Elements( Line( X, Y, Legend( 20 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Time [years]",
			ScaleBox,
			{Label Row( Show Major Grid( 1 ) )}
		),
		Dispatch( {}, "Data", ScaleBox, {Label Row( Show Major Grid( 1 ) )} )
	)
)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Legend&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;To make the legend show the&amp;nbsp;manufacturer and car together create a column that concatenates the&amp;nbsp;manufacturer name with the car name.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column( "Man:Car",
	Character,
	"Nominal",
	Formula( :Manufacturer || " " || :Label ),
	Set Selected,
	Set Display Width( 108 )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Plot Points Instead&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Another idea: Instead of trying to display that many lines, could you instead summarize each curve into whatever you are actually trying to visualize?&amp;nbsp; For the [i assume] simplified line example, you could plot individual points for each car showing the slope and intercept.&amp;nbsp; Two thousand points on a chart are easier to interpret&amp;nbsp;than 2000 lines. At some point I still give up on the legend though).&amp;nbsp; Here I started with the long table and did a fit model 'by' the Man-Car column created above, then saved the estimates table as a combined table, split the table by term, then graphed:&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-inline" image-alt="summarized chart.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/7975iD23D341B661B51B9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="summarized chart.png" alt="summarized chart.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 22:33:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45870#M26155</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2017-10-12T22:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the color of curves based on condition on the data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45875#M26158</link>
      <description>&lt;P&gt;Hello &lt;A href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6657" target="_blank"&gt;&lt;FONT color="#0066cc"&gt;ih&lt;/FONT&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Among your options, the solution called "plotting lines" is perfect and exactly what I wanted !!!&lt;/P&gt;&lt;P&gt;It is even excellent because it does not envolve complex scripting !&lt;/P&gt;&lt;P&gt;So basically, you propose to:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;add a column "Manufacturer-Car"&lt;/LI&gt;&lt;LI&gt;Use this column as Overlay&lt;/LI&gt;&lt;LI&gt;Color by manufacturer&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;And the result is perfect (I nerver really understood how the Overlay and color could be combined, now I see an example):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Graph Builder.png" style="width: 711px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/7976iA8E505377B3CC615/image-size/large?v=v2&amp;amp;px=999" role="button" title="Graph Builder.png" alt="Graph Builder.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 04:22:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-change-the-color-of-curves-based-on-condition-on-the-data/m-p/45875#M26158</guid>
      <dc:creator>samir</dc:creator>
      <dc:date>2017-10-13T04:22:16Z</dc:date>
    </item>
  </channel>
</rss>

