Subscribe Bookmark RSS Feed

Re: How do I change the X-axis in Graph Builder and JSL so Nominal X-variables share same space/name

liqinglei419

New Contributor

Joined:

Jan 10, 2018

Hi there!

 

I have been trying to  create a script that graphs a parameter of a multiple samples. The samples are named in such a way that it is XX-AA, where XX is the ID/name of the sample, and AA is the timestamp of the sample (day 1,2,3, and so forth).

 

My current issue is that I am trying to plot multiple samples on top of each other using the graph builder, and also seeing what changes I can do within the JSL script. The intention is to have the graph plot a parameter Y against the formatted sample nomenclature XX-AA, but to change the X-axis labels so that it plots against the timestamp AA.

 

I currently have a Graph Builder script for two samples, FJ and WW. I do plan to add more different samples in to plot on top of each other, so another issue that comes to light is the inefficiency of the script as seen below. In addition you can see from the attachment that FJ and WW are not really on top of each other, and the X-axis ends up looking like 2,4,6,8 then followed by another 2,4,6,8.

 

 

Graph Builder(
       Size( 532, 447 ),
       Show Control Panel( 0 ),
       Variables( X( :Sample ), Y( :Mass ), Overlay( :Sample Name ) ),
       Elements( Points( X, Y, Legend( 3 ), Jitter( 0 ) ), Line( X, Y, Legend( 4 ) ) ),
       SendToReport(
             Dispatch(
                    {},
                    "Sample ID",
                    ScaleBox,
                    {Label Row(
                          {Tick Mark( Label( "FJ-02" ), Label( "2" ) ),
                          Tick Mark( Label( "FJ-03" ), Label( "3" ) ),
                          Tick Mark( Label( "FJ-04" ), Label( "4" ) ),
                          Tick Mark( Label( "FJ-05" ), Label( "5" ) ),
                          Tick Mark( Label( "FJ-06" ), Label( "6" ) ),
                          Tick Mark( Label( "FJ-07" ), Label( "7" ) ),
                          Tick Mark( Label( "FJ-08" ), Label( "8" ) ),
                          Tick Mark( Label( "WW-02" ), Label( "2" ) ),
                          Tick Mark( Label( "WW-03" ), Label( "3" ) ),
                          Tick Mark( Label( "WW-04" ), Label( "4" ) ),
                          Tick Mark( Label( "WW-05" ), Label( "5" ) ),
                          Tick Mark( Label( "WW-06" ), Label( "6" ) ),
                          Tick Mark( Label( "WW-08" ), Label( "8" ) )}
                    )}
             ),
             Dispatch( {}, "X title", TextEditBox, {Set Text( "Time (days)" )} )
       )
)

 

 

One way I was thinking of solving the issue was to have the script create a new column that would only indicate the day by only looking at the timestamp (AA) component of the sample name's format of XX-AA. I was wondering if there are also alternative methods that may be more efficient/effective.

 

Thank you in advance!

 

unintended graph.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
mjoner

Community Trekker

Joined:

Jun 23, 2011

Solution

In your original post, your script contains this line:

      Variables( X( :Sample ), Y( :Mass ), Overlay( :Sample Name ) ),

Try replacing it with this:

      Variables(
            X( Transform Column( "Day", Formula( Num( Word( 2, :Sample, "-" ) ) ) ) ),
            Y( :Mass ),
            Overlay( :Sample Name )
      ),

 Edit: you'll probably also need to delete your SendToReport block if you do it this way.

2 REPLIES
mjoner

Community Trekker

Joined:

Jun 23, 2011

Solution

In your original post, your script contains this line:

      Variables( X( :Sample ), Y( :Mass ), Overlay( :Sample Name ) ),

Try replacing it with this:

      Variables(
            X( Transform Column( "Day", Formula( Num( Word( 2, :Sample, "-" ) ) ) ) ),
            Y( :Mass ),
            Overlay( :Sample Name )
      ),

 Edit: you'll probably also need to delete your SendToReport block if you do it this way.

Highlighted
liqinglei419

New Contributor

Joined:

Jan 10, 2018

Thanks so much! I really appreciate it!