Subscribe Bookmark RSS Feed

Reference line

statganda

Community Trekker

Joined:

Jun 23, 2011

Dear community,

Is there any script that I can use to add different reference line to a multiple distribution chart. I have 4000 histograms & each one of them have different reference value.

Your help is really appreciated.

Thanks
7 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Here is a sample script, assuming all histograms are within the same window. The individual ref lines are here simply the group mean, but the script can easily be adapted to a custom matrix or list of values, e.g. retrieved from a table

statganda

Community Trekker

Joined:

Jun 23, 2011

Hi MS,

Thanks. It works.

More power to you
anneg

Community Trekker

Joined:

Jun 23, 2011

Hello,

I've got a similar problem, I have a graph and on the x-axis there is a date (like d.m.y), and I want several vertical ref lines on the a-axis. To day i used a script with v-line, but there I got the line, but no label on it.

The dates for the ref lines and the label are stored in a data table (column date (format d.m.y), column label). But the manual refline uses instead of the date a number like: 33962554400 (and I know this is a date...)

Graph Builder( Size( 696, 688 ), Show Control Panel( 0 ), Variables( X( :BL, Size( 212 ) ), Y( :Name( "x" ) ), Group Y( :Name( "s_-x" ) ), Overlay( :Projektklasse_plus ) ), Elements( Points( X, Y, Legend( 6 ) ) ), SendToReport( Dispatch( {}, "BL-date", ScaleBox, {Format( "d.m.y", 10 ), Interval( "Day" ), Inc( 1 ), Add Ref Line( 3396254400, Solid, {255, 0, 0}, "Label ref line 1" ) , Rotated Labels( 1 )} ), Dispatch(.......

my vline script was like this:

OPR[FrameBox(1)] << add graphics script (pen color("purple"); vline(column(data Table ("CHCharge$"),"CuI") << get values));

but actually i want really different ref lines with a label, on different dates and the data table with the dates for the ref lines is getting more and more dates in it throughout the year...

So can you please clarify your answer, how to use a data table?

Thanks in advance.

ms

Super User

Joined:

Jun 23, 2011

The strange number is JMPs internal representation of a datetime value (actually the nr of seconds since a reference date I keep forgetting...).

VLine() seems not to have an optional label argument. But you can populate the graph with vertical lines using Add ref line() in a for loop. Use Summarize() to get lists and matrices of the labels and dates from the data table. See example script below.

// Make example table

dt=New Table( "Test",

          Add Rows( 6 ),

          New Column( "Group",Nominal, Character, Set Values(

                              {"Group A", "Group A", "Group A", "Group B", "Group B", "Group B"})),

  New Column( "Data", Numeric,

                    Set Values( [1, 2, 3, 2, 3, 4] )),

  New Column( "Date", Numeric,

                    Format( "d-m-y", 12 ),

                    Set Values([3166214400, 3166300800, 3166387200, 3166214400, 3166300800, 3166387200])),

          New Column( "Label",Nominal,Character,

                    Set Values( {"A", "B", "C", "A", "B", "C"} )));

// Make list of dates and labels

Summarize(dlist=by(:Date),dlist=mean(:Date));

Summarize(llist=by(:Label));

// Make graph

gb=Graph Builder(

          Variables( X( :Date ), Y( :Data ), Overlay( :Group ) ),

          Elements( Points( X, Y, Legend( 1 ) ) ));

//Add vertical reflines based on dates in Column date

for(i=1,i<=nrows(dlist),i++,

report(gb)[Axis Box(1)] << add ref line (dlist[i],Solid, "Purple", llist[i] ));

I hope this helps.

anneg

Community Trekker

Joined:

Jun 23, 2011

It helped, but I still got an error,

I've got 2 different tables, one table I use for the graph, in the secon there are the dates (report "Verlauf Eta A6") and labels for ref lines (data table "")- I  changed allready the format to the jmp long date number:

for(i=1,i<=nrows(data Table ("Ereignisse")),i++, report("Verlauf ETA A6")[Axis Box(1)] << add ref line (column(data Table ("Ereignisse"),"Datum"),Solid, "Purple", column(data Table ("Ereignisse"),"Bezeichnung") ));

but the Log returns the following (not very helpful)

In the following script, error marked by /*###*/ For( ::i = 1, ::i <= N Rows( Data Table( "Ereignisse" ) ), ::i++, Report( "Verlauf ETA A6" )[Axis Box( 1 )] <<  /*###*/ add ref line( Column( Data Table( "Ereignisse" ), "Datum" )[::i], Solid, "Purple", Column( Data Table( "Ereignisse" ), "Bezeichnung" )[::i] ) /*###*/ )

ms

Super User

Joined:

Jun 23, 2011

I am not sure what "Verlauf ETA A6" is for kind of Object. If it's a name of the graph bulider object it should work, however if it's the name of the data table it does not work. I think it is easier to assign a variable to the Graph builder window (as above

Besides that, it should work. I changed my script to retrieve the reflines from a separate table using your syntax and it worked.

I also think that you may need to make sure that the right table is the "current data table".

sfo

Community Member

Joined:

Mar 2, 2012

I have a similar problem. I have a proc gplot that is plotting 35 different charts for different id's using a by statement. Is there a way I can specify different horizontal reference line in each plot? And, is it also possible to display the value of that reference line either on top or bottom of the line?

Thanks