comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » automatic placement of legend in 2-D graph
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: automatic placement of legend in 2-D graph [message #58491 is a reply to message #58172] Wed, 30 January 2008 14:49 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jean-Paul Davis writes:

> I thought I would share this in case someone finds it useful. After
> spending a shameful amount of time barking up wrong trees, I finally
> hit on a very simple solution to (semi-) automatic legend placement:
>
> 1. determine the legend's boundaries in device coordinates (i.e.,
> pixels in the window)
> 2. hide the legend and redraw
> 3. get the window's image_data property
> 4. loop through possible legend positions (in device coordinates) to
> find one that has the fewest (preferably zero) non-background-color
> pixels in the region of the image defined by the legend boundaries
> 5. translate the legend accordingly, unhide it, and redraw

Now *that* is what I call a good algorithm. Simple enough even
I can understand it! :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Travel Destination: Holland
Next Topic: Re: Re-gridding Problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 02:57:39 PDT 2025

Total time taken to generate the page: 0.79313 seconds