Subscribe Bookmark RSS Feed

Change drawing order of graphics elements using JSL

Highlighted
nkelleh

Community Trekker

Joined:

Dec 19, 2012

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
Solution

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.

6 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Dec 19, 2012

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

Staff

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Dec 19, 2012

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});

    );

  

);

Solution

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

Community Trekker

Joined:

Dec 19, 2012

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