Re: adding legend with cgzplot [message #83172] |
Fri, 08 February 2013 04:57 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
idlhelp writes:
> I want to add the legend in the plot. And for making plots I am using cgZplot. But I don't know how to add legend with that. This is how I am doing but it doesn't work.
>
> oplotObj = Obj_New('CGOVERPLOT',a,b,color='red')
> cgZplot,c,d,color='black',OPLOTS=oplotObj
> legend,['Temp','Days'],linestyle=[0,0],color=['black','red']
>
>
> Does anyone know how to do that
As explained in the on-line documentation for the LEGEND keyword:
oplotObj = Obj_New('CGOVERPLOT',findgen(101), $
cgDemodata(17),color='red')
legendItem1 = Obj_New('cgLegendItem', Color='black', $
Location=[0.775, 0.875], Title='Temp', Length=0.05)
legendItem2 = Obj_New('cgLegendItem', Color='red', $
Location=[0.775, 0.835], Title='Days', Length=0.05)
cgZplot,findgen(101), cgDemodata(17),color='black',$
OPLOTS=oplotObj, LEGEND=[legendItem1, legendItem2], $
YRange=[0,125]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|