;+ ; NAME: drawscalebar ; PURPOSE: ; Draw a scalebar on an image. ; NOTES: ; Requires the data coordinates to be set up in ARCSECONDS for this ; to work properly ; ; INPUTS: ; au how many AU long the scale bar should be ; distance distance to the source (sets AU to arcsec conversion) ; KEYWORDS: ; OUTPUTS: ; ; HISTORY: ; Began 2004-5-24 by Marshall Perrin ; Documentation added long after the fact, 2005-04-19 ;- PRO drawscalebar,au,distance,x,y,thick=thick,_extra=_extra,pos=pos,ends=ends,xtext=xtext if ~(keyword_set(ends)) then ends=10 if ~(keyword_set(xtext)) then xtext=1.5 ; this lets us set xthick and ythick to some other value for postscript ; yet still produce nice looking plots on screen. if !d.name eq "X" then begin thick=1 endif else begin if not(keyword_set(thick)) then thick=3 endelse scalebarlen = au*1.0/distance ; in arcseconds ylen = scalebarlen/ends ; relative height for endcaps of line plot if keyword_set(pos) then begin xbar = pos[0] ybar = pos[1] ytext = pos[1]-ylen endif else begin xbar = (x[n_elements(x)-1]-x[0])*0.07+x[0] ybar = (y[n_elements(y)-1]-y[0])*0.07+y[0] ytext = (y[n_elements(y)-1]-y[0])*0.06+y[0] endelse if x[0] lt x[n_elements(x)-1] then xsign=1.0 else xsign = -1.0 plots,[xbar,xbar+scalebarlen*xsign],[ybar,ybar],_extra=_extra,color=fsc_color('white'),thick=thick plots,[xbar,xbar],[ybar+ylen,ybar-ylen],_extra=_extra,color=fsc_color('white'),thick=thick plots,[xbar+scalebarlen*xsign,xbar+scalebarlen*xsign],[ybar+ylen,ybar-ylen],_extra=_extra,color=fsc_color('white'),thick=thick xyouts,xbar+xtext*scalebarlen*xsign,ytext,strc(au)+ " AU",color=fsc_color('white'),_extra=_extra end