draw order

83 views
Skip to first unread message

Brian McNoldy

unread,
Jun 24, 2024, 1:44:24 PM6/24/24
to idl-pvwave
I am creating fairly basic line plots, they just happen to have quite a few lines on them.  But the issue I'm struggling with is the draw order.  I would expect that the first thing to be plotted would be the furthest "back", and each new item added to a plot would go on top of the previous.
ohc_gulf.png
ohc_carib_anom.png
On these examples, the blue line gets drawn first, then the thin gray lines, then the dark red line, then the dashed red "crosshair" lines, then the bright red line, then the symbol with text label.  (The legend and map come next, but those aren't relevant to this question.)

In several examples, the same behavior occurs, and it occurs whether I write the plot out to the screen or to the buffer.  Since the red dot "symbol" and its black text label are drawn AFTER all of the lines, why does it appear UNDER the lines?

Nothing strange going on in the code, just multiple PLOT calls (with "overplot") followed by a SYMBOL call.
I tried something like:
sym=symbol(....)
sym.order,/bring_to_front
but that had no effect.

Thanks,
Brian

Ben C

unread,
Jun 24, 2024, 4:42:27 PM6/24/24
to idl-pvwave
This "order" issue is a known bug in IDL. 

The best work-around currently is to disable antialiasing on PLOT which should resolve your problem, albeit with slightly more jaggies:

 e.g.    P  = PLOT(......,ANTI=0). 

markus.sc...@gmail.com

unread,
Jun 25, 2024, 5:33:36 AM6/25/24
to idl-pvwave
Another approach, which gives better results but is more difficult, is saving as eps, then opening the eps in a text editor, and switching the order there.
Assuming one of the earlier lines (e.g. line 17) is  /R/setrgbcolor ld, then lines consisting of 3 numbers followed only by an R, set the color, this shows you where lines start in the eps file.

Brian McNoldy

unread,
Jun 25, 2024, 8:17:53 AM6/25/24
to idl-pvwave
Ahh, thanks Ben... that's helpful, at least so I don't keep trying to make it work and wondering what I'm doing wrong!  I guess I just haven't noticed it happening to the extent I do on the type of plots I shared as examples (where the symbol object and its label gets placed at the bottom despite being plotted last).

Cheers,
Brian

Brian McNoldy

unread,
Jun 25, 2024, 8:23:15 AM6/25/24
to idl-pvwave
Thank you Markus... I wouldn't mind doing that for a once-and-done task like a publication figure, but these are a series of plots that are produced every day (https://bmcnoldy.earth.miami.edu/tropics/ohc/)... so for my application it's not practical to edit the EPS files.  If the ordering issue didn't happen to EPS output, I could save as an EPS and convert to PNG like I used to do many moons ago before the 8.0 graphics and the SAVE method (thankfully) came along.

Regards,
Brian

Brian McNoldy

unread,
Jan 25, 2025, 10:21:39 AMJan 25
to idl-pvwave
Just curious if there have any advances on this topic since last June.  I'm running 9.0.0 and the draw order is still not controllable when saving as a PNG.  (antialias on or off)

Thanks!
Brian

Brian McNoldy

unread,
Mar 26, 2025, 8:42:56 AMMar 26
to idl-pvwave
This is becoming a major problem... I can't make usable plots if I can't control the draw order in a saved PNG file.  Still using 9.0 on Linux, and nothing I have tried fixes it (buffer, hardware vs software rendering).  Is anyone experiencing this?  For example, long tick marks get plotted on top of a legend, map gridlines get plotted over filled continents (despite the order in the code being appropriate).

Thanks,
Brian

Reply all
Reply to author
Forward
0 new messages