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

Home » Public Forums » archive » Re: Legend for plot
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: Legend for plot [message #67979 is a reply to message #67978] Tue, 15 September 2009 21:19 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Sep 15, 9:58 pm, "b.a" <u4565...@anu.edu.au> wrote:
> Thanks for your solution. But I couldn't get it to work. What happens
> now, is that I get 3 separate window: one for my GUI (a simple tlb and
> draw widget), one for the legend (but the legend doesn't appear in it)
> and one for my plots.

The first empty one is because you are making an empty window object
(in mywindow = OBJ_NEW('IDLgrWindow')), and as such it will show up on
its own, not in your draw widget. Remove that line. The window object
you want is the one in the draw widget.

> as you see, I have commented this line:
>  ;mywindow->Draw, myview
>
> If I don't do that, it gives error:
> Unable to invoke method on NULL object reference: <OBJREF
> (<NullObject>)>.
> ehich I think means that mywindow is a null object.

Sorry, forgot to say that the widget must be realized before you ask
for the
window object. That is why it was null at that point.

The third window is created by your call to plot. Plot is a direct
graphics routine, so it cannot draw on your widget_draw. You must put
object graphics in your view object, as you did with the legend. For a
plot, it usually means making and setting up a bunch of them (plots,
axes, titles, symbols). I usually prefer to make an invisible iplot
and borrow its view object, so that iplot does all the work of making
and setting up the objects in the plot.

Without getting into how to make the plots, your code would work as

pro demolegend

x1 = [1,2,3,4,5]
y1 = [4,5,6,7,8]

x2 = [2,3,4,4.5,5]
y2 = [4,5,6,7,8]

tlb = Widget_Base(column=1, XSIZE=350, YSIZE= 400,$
XOFFSET=250, YOFFSET= 300)

dr_window = WIDGET_DRAW(tlb, UVALUE= 'draw', $
XSIZE= 348, YSIZE=200, GRAPHICS_LEVEL = 2)

myview = OBJ_NEW('IDLgrView')

itemNameArr = ['One', 'two']

myLegend = OBJ_NEW('IDLgrLegend', itemNameArr)
myview->Add, mylegend

Widget_Control, tlb, /realize
WIDGET_CONTROL, dr_window, GET_VALUE = mywindow
mywindow->Draw, myview

;plot, y2, x2, COLOR= 40, BACKGROUND= 255
;oplot, y1, x1, COLOR= 80

Xmanager, 'demolegend', tlb

end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL on the web?
Next Topic: iplot colorbar label

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

Current Time: Thu Oct 09 21:18:52 PDT 2025

Total time taken to generate the page: 0.40077 seconds