How to Create a Legend for a Plot in IDL
 
 In this example, a sample bit of the line style used for each data set is placed, using PlotS, in a vacant part of the graph.  Then, next to it, the data set name is placed using XYOutS.
 
x=findgen(10)
y=x*2
z=y-3

plot, x, y
oplot, x,z, linestyle=1
plots, [0.8,2], [18.5,18.5]
plots, [0.8,2], [17,17], $    linestyle=1
xyouts, 2.3, 18.5, 'Data Set y'
xyouts, 2.3, 17, 'Data Set z'