Re: Colors in xy-plots

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon, 11 Sep 2006 13:42:08 -0600

Hi Arne,

I definitely think that it is possible, although decently complicated.
After filling out an array of colors, I decided the best course of
action was to draw individual lines (for each data point) and not
advance the frame. Others can chime in if they can think of a better

In the following I will assume that you are manually setting the
cnFillColors = mycolors in your contour plot resource list, and I will
also assume that delta-X is a constant. Hopefully this will at least get
you on the right track. Good luck. Adam

; untested!
; data = 1D array with crosssection values

datacolor = new(dimsizes(data),typeof(data))
nlevels = dimsizes(myintervals)

do gg = 0,nlevels-1 ; loop thru each level
    if (gg.eq.0) then
       temp = ind(
       temp = ind(
    end if
    if (.not.ismissing(temp)) then
       datacolor(temp) = mycolors(gg)
    end if
    if (gg.eq.(nlevels-1)) then ; special case for last contour level
       temp2 = ind(
       if (.not.ismissing(temp2)) then
          datacolor(temp2) = mycolor(gg+1)
       end if
    end if
end do

deltaX = 1. ; you will have to likely change this
xarray = ispan(1,10,1) ; and this

halfdX = deltaX/2.0
res = True
res_at_gsnFrame = False

do hh = 0,dimsizes(datacolor)-1
    res_at_xyLineColor = datacolor(hh)
    if (hh.eq.0) then
       xarr = (/xarray(hh),xarray(hh)+halfdX/)
       dumdata = (/data(hh),((data(hh)+data(hh+1))/2.0) /)
    end if
    if ( then
       xarr = (/xarray(hh)-halfdX,xarray(hh)+halfdX/)
    end if
    if (hh.eq.(dimsizes(datacolor)-1) then
       xarr = (/xarray(hh)-halfdX,xarray(hh)/)
       dumdata = (/((data(hh-1)+data(hh))/2.0),data(hh) /)
    end if
    plot = gsn_csm_xy(wks, xarr, dumdata,res)
end do

Arne Melsom wrote:
> Hi all,
> Is there a way to apply color shading to a xy plot curve? I have a 2D
> contour plot of SSH with a shading defined by the resources
> res_at_cnLevelSelectionMode = "ExplicitLevels"
> res_at_cnLevels = myintervals
> the latter being a 1D array that's defined elsewhere. Now, I extract
> values in a crossection (i.e., along a line), and would like to display
> the extracted values as a multi-color curve in a xy plot, using the
> shading from the contour plot. Is this possible?
> Many thanks!
> -Arne
> _______________________________________________
> ncl-talk mailing list

Adam Phillips			   
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000
ncl-talk mailing list
Received on Mon Sep 11 2006 - 13:42:08 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 11 2006 - 16:31:47 MDT