Re: Contour and Pattern Fill in NCL

From: Mary Haley (haley AT unknown)
Date: Fri May 07 1999 - 14:16:12 MDT


> I am trying to plot OMEGA (in this case) from CSM with
> a hatching (i.e a pattern) over all positive values
> with a solid contour fill underneath.
>
> I tried the following
> "cnFillOn" : "True"
> "cnMonoFillColor" : "False"
> "cnFillColors" : (/2,4,6,8,10,10,8,6,4,2/) ; contour fill colors
> "cnMonoFillPattern" : "False"
> "cnFillPatterns" : (/3,3,3,3,3,-1,-1,-1,-1,-1/)
>
> In this case the hatches aquire the colors that I specified
> and there is no underlaying solid countouring. The label bar
> contains the hatches as well, but not the contours.
>
> I have also tried creating two separate contour objects
> and then using the overlay function.
>
> One object draws the fill colors and the other object draws the
> fill patterns. This script can be seen at
> http://www.psu.edu/~jfd/omega.ncl. The plot can be viewed
> at http://www.psu.edu/~jfd/omega.html.
>
> In this case the plot is exactly as I want it, but
> the labelbar does not contain the pattern fill.
>
> Any help with this would be appreciated.
>
> Thanks,
>
> Jan Dutton
>

Dear Jan,

I was unable to access your web page above, but I think I understand
what you are trying to do. Below is a little NCL script I wrote
showing how to get both solid fill and hatching. It is not possible
to specify both hatching and solid filled colors in one step, so your
approach was correct in trying to do it in two steps.

I first created and drew the contour plot with solid color fill, using
a different color for each contour level. I then called "setvalues"
on this contour plot to indicate that I wanted to fill each contour
level with a black hatching pattern. I then drew the contour plot
again, this time getting the black hatching pattern. Here's the
script:

begin

;
; create a simple bull's eye pattern test data set
;
  M=25
  N=25
 
  T = new((/N,M/),float)
 
  jspn = ispan(-M/2,M/2,1)^2
  ispn = ispan(-N/2,N/2,1)^2
  do i = 0, dimsizes(ispn)-1
    T(i,:) = ispn(i) + jspn
  end do
  T = 100.0 - sqrt(8^2 * T)

;
; Create an X11 workstation.
;
  wid = create "cn01Work" xWorkstationClass defaultapp end create

;
; Create a ScalarField data object using the data set defined above.
;
  dataid = create "bullseye" scalarFieldClass defaultapp
    "sfDataArray" : T
  end create

;
; Create a ContourPlot object, supplying the ScalarField object as data.
;
;
;
  cnid = create "ContourPlot1" contourPlotClass wid
    "cnFillOn" : True ; Turn contour fill on.
    "cnScalarFieldData" : dataid
    "pmLabelBarDisplayMode" : True
    "lbPerimOn" : False
  end create

  draw(cnid) ; Draw a contour plot filled with solid colors.

  setvalues cnid
    "cnMonoFillPattern" : False ; Indicate multiple fill patterns
    "cnLineLabelsOn" : False ; Don't draw line labels again.
    "cnMonoFillColor" : True ; Draw patterns in one color.
    "cnFillColor" : 0 ; Indicate color of patterns (black).
  end setvalues

  draw(cnid) ; Draw same contour plot with black hatching patterns.

  frame(wid)
    
end

Hope this is what you are looking for! Let me know if you have any
questions.

--Mary



This archive was generated by hypermail 2b29 : Wed Jun 28 2000 - 09:40:37 MDT