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

Home » Public Forums » archive » Adding straight lines to a plot
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Adding straight lines to a plot [message #73474] Thu, 11 November 2010 14:28 Go to next message
fgg is currently offline  fgg
Messages: 67
Registered: April 2010
Member
Hi,

Is there a function in IDL to add a straight line through an existing
plot? Something like the 'abline' function in R, where all you need is
to specify the y-value for a horizontal line (or the x-value for a
vertical line).

Thanks
Re: Adding straight lines to a plot [message #73555 is a reply to message #73474] Fri, 12 November 2010 06:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul van Delst writes:

>
> David Fanning wrote:
>> fgg writes:
>>
>>> Is there a function in IDL to add a straight line through an existing
>>> plot? Something like the 'abline' function in R, where all you need is
>>> to specify the y-value for a horizontal line (or the x-value for a
>>> vertical line).
>>
>> Here you go.
>>
>> PRO ABLine, value, $
>> VERTICAL=vertical, $
>> LINESTYLE=linestyle, $
>> THICK=thick, $
>> COLOR=color
>>
>> IF N_Elements(color) EQ 0 THEN color = 'white'
>>
>> IF Keyword_Set(Vertical) THEN BEGIN
>> PLOTS, [value, value], [!Y.CRange[0], !Y.CRange[1]], $
>
> why not simply
> PLOTS, [value, value], !Y.CRange, $
>
>> LINESTYLE=linestyle, THICK=thick, $
>> COLOR=FSC_Color(String(color))
>> ENDIF ELSE BEGIN
>> PLOTS, [!X.CRange[0], !X.CRange[1]], [value, value], $
>
> and similarly
> PLOTS, !X.CRange, [value, value], $
>
> ?

Pedantry. :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Adding straight lines to a plot [message #73556 is a reply to message #73474] Fri, 12 November 2010 06:37 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Nov 12, 9:32 am, Paul van Delst <paul.vande...@noaa.gov> wrote:
> David Fanning wrote:
>> fgg writes:
>
>>> Is there a function in IDL to add a straight line through an existing
>>> plot? Something like the 'abline' function in R, where all you need is
>>> to specify the y-value for a horizontal line (or the x-value for a
>>> vertical line).
>
>> Here you go.
>
>> PRO ABLine, value, $
>>     VERTICAL=vertical, $
>>     LINESTYLE=linestyle, $
>>     THICK=thick, $
>>     COLOR=color
>
>>    IF N_Elements(color) EQ 0 THEN color = 'white'
>
>>    IF Keyword_Set(Vertical) THEN BEGIN
>>        PLOTS, [value, value], [!Y.CRange[0], !Y.CRange[1]], $
>
> why not simply
>          PLOTS, [value, value], !Y.CRange, $
>
>>           LINESTYLE=linestyle, THICK=thick, $
>>           COLOR=FSC_Color(String(color))  
>>    ENDIF ELSE BEGIN
>>        PLOTS, [!X.CRange[0], !X.CRange[1]], [value, value], $
>
> and similarly
>          PLOTS, !X.CRange, [value, value], $
>
> ?
>
>
>
>
>
>
>
>>           LINESTYLE=linestyle, THICK=thick, $
>>           COLOR=FSC_Color(color)
>>    ENDELSE
>
>> END
>
>> Cheers,
>
>> David

You can do the same thing in NG with polyline(/data), where xrange and
yrange are properties of the graphic object.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Adding straight lines to a plot
Next Topic: Good-bye Contour Command

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

Current Time: Wed Oct 08 19:29:57 PDT 2025

Total time taken to generate the page: 0.00584 seconds