cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
nkelleh
Level III

Change drawing order of graphics elements using JSL

Hi All,

I know you can change the drawing order of graphics elements by right clicking on a graph, then clicking customize, and then moving the order of the graphics scripts using the up/down arrows. Is there a way to do this using JSL? There are messages you can send to the Framebox to change the order of grid lines and reference lines, I was hoping there would be something similar for markers. Also can you change the transparency of things like fitted lines, etc. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Change drawing order of graphics elements using JSL

Have you tried just appending the markerseg back to the frame after deleting it?

  1. markerSeg1 = bivFrame << Find Seg( Marker Seg(1) );
  2. markerSeg1 << Delete;
  3. bivFrame << appendseg(markerSeg1);

That should make it last in the draw order.  Deleting it just removes it from the tree, so it should be safe to add back.

View solution in original post

7 REPLIES 7
ian_jmp
Level X

Re: Change drawing order of graphics elements using JSL

FYI, you can do this kind of thing (so with the ability to change the order of the grid and reference lines you may be able to get what you want):

Names Default To Here( 1 );

Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = Bivariate( Y( :weight ), X( :height ), FitLine );

rbiv = biv << report;

framebox = rbiv[frame box( 1 )];

Wait(1);

framebox <<

Add Graphics Script(

1,

Description("Orange Polygon"),

Transparency( 0.5 );

Fill Color( {1.0, 0.5, 0.0} );

Polygon( [60, 72, 57], [75, 120, 120] );

);

Wait(1);

framebox <<

Add Graphics Script(

2,

Description("Blue Polygon"),

Transparency( 0.5 );

Fill Color( {0.0, 0.5, 1.0} );

Polygon( [60, 72, 57], [150, 120, 120] );

);

Wait(1);

framebox << Remove Graphics Script( 1 );

// Having removed the first graphics script, the second is now in position 1 (even though it was assigned originally to position 2) . . .

Wait(1);

framebox << Remove Graphics Script( 1 );

Also, please see: https://www.jmp.com/support/help/Adding_Scripts_to_Graphs.shtml

nkelleh
Level III

Re: Change drawing order of graphics elements using JSL

Hi Ian,

Thanks again, useful tips. Here, I want to keep the other graphics elements, in this case fitted splines, but bring the markers to front of the plot (The lines of the spline fit are obscuring the markers in areas where a lot of lines/markers are close together. I can do this manually using the method described in the original post, just wondering if there is any way of doing this programmatically doing it. Its unfortunate a 'marker order' message wasn't included along with the 'Reference Line Order' and 'Grid Line' Order messages for the Frame Box.

Its easy to change the transparency of objects drawn using a graphics script. On another note, I was wondering is there any way of changing the transparency of fitted lines in, say, the Bi-variate platform.

Thanks again for all your help.

ian_jmp
Level X

Re: Change drawing order of graphics elements using JSL

Sorry - Now I get it.

In the hope that someone will prove my wrong, I'll say that you are 'out of luck', unfortunately. Both in terms of twiddling the up/down arrows programmatically, and the transparency of the fitted lines.

Not necessarily recommended, but if you want to bring the markers to the front you could consider redrawing them with a graphics script using a variation of: https://community.jmp.com/thread/65641

nkelleh
Level III

Re: Change drawing order of graphics elements using JSL

Ah well, had to ask just in case!

Thanks for the workaround, I was able to get the output I was looking for by deleting the existing markers and redrawing them as the thread you linked suggested. You lose the platform interactivity in terms of selecting data points, but as this was for purely data visualization purposes, that was fine with me.

Thanks again.

Below is the segment of code I reused to delete the markers and redraw them

//Delete Markers if required

markerSeg1 = bivFrame << Find Seg( Marker Seg(1) );

markerSeg1 << Delete;

//Script to redraw markers on top

bivFrame << Add Graphics Script(

    For(r=1, r <= NRows(dtMain), r++,

  

        y = Column( dtMain, "Voltage" );

        x = Column( dtMain, "Temp" );

        ms = Combine States(

            Marker State( Marker Of( Row State( r ) ) ),

            Color State( Color Of( Row State( r ) ) )

        );

      

        Marker(ms, {x, y});

    );

  

);

Re: Change drawing order of graphics elements using JSL

Have you tried just appending the markerseg back to the frame after deleting it?

  1. markerSeg1 = bivFrame << Find Seg( Marker Seg(1) );
  2. markerSeg1 << Delete;
  3. bivFrame << appendseg(markerSeg1);

That should make it last in the draw order.  Deleting it just removes it from the tree, so it should be safe to add back.

nkelleh
Level III

Re: Change drawing order of graphics elements using JSL

Actually, that works too. Don't know why I didn't think of trying that. Cheers.

drew_baumgartel
Level III

Re: Change drawing order of graphics elements using JSL

Using JMP 14.2, the customize graph options work with jsl commands like this, with the values of "Window" and "Frame Box" variable, and hence arbitrary for this example:

 

Window(6)[Frame Box( 1 )] << Dispatch( {}, "Oneway Plot", FrameBox, {Grid Line Order( 3 )}) 

                                              

I'm able to do this trick to have the grid lines appear on top of the markers for the bivariate, variability plot, and contour plot platforms, but I can't get it to work for the Oneway platform beyond a value of 3. The Marker is in the 5th position by default, so I need the grid line order to be after that. While the above command with Grid Line Order( 2 ) or Grid Line Order( 3 ) works fine, nothing happens when I use Grid Line Order( 4 ) or Grid Line Order( 5 ). I believe this is a bug.

 

If I do the point and click and force grid line order to be 5, and then save script to script window, I get "Grid Line Order( 5 ), Reference Line Order( 1 )", but running the script as is from the script window doesn't even put the grid lines in the 5th position.

 

I'll echo the comment of @nkelleh: "Its unfortunate a 'marker order' message wasn't included along with the 'Reference Line Order' and 'Grid Line' Order messages for the Frame Box." JMP allowing options like 'After/Before' or 'Last/First', the way it does with arranging columns or rows in a data table, would be helpful here as well.