On Thu, 21 Jun 2007, James Fishbaugh wrote:
> Hello,
>
> I would like to be able to display a contour plot of constant data in
> the appropriate color. However, regardless of what the constant is
> (zero in this case), the plot will always be white whereas the value
> of zero should be a light purple. Is there anyway I can get it to
> plot a solid color across the domain? Thanks.
>
> James
Hi James,
I'm afraid there's is no way to set resources and have them apply to
a constant-field contour plot. It's at the very low level of NCL where
it handles this thing, and it basically considers a constant field to
not be a contour plot.
Dave Brown said a possible workaround might be to perturb the field
with a single value that is slightly different from the constant
value, but arranging the contour levels such that this value falls
within the same level space. We're not sure if this would work though.
Another (kludgy) work-around might be to just fill in the plot area
yourself with the color you want, using gsn_polyline or
gsn_add_polyline.
Here's a simple example:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
ny = 20
nx = 20
z = new ( (/ny,nx/), "float" )
z = 0.0
wks = gsn_open_wks("x11","constant")
res = True
res_at_cnFillOn = True
if(min(z).eq.max(z)) then
res_at_gsnDraw = False ; Don't draw plot or
res_at_gsnFrame = False ; advance frame yet.
res_at_lbLabelBarOn = False ; Don't draw labelbar.
plot = gsn_csm_contour(wks,z,res)
; Retrieve axes limits
getvalues plot
"trXMinF" : xmin
"trXMaxF" : xmax
"trYMinF" : ymin
"trYMaxF" : ymax
end getvalues
; Use axes limits to add a filled box around plot area.
gsres = True
gsres_at_gsFillColor = "LightBlue" ; Use whatever color is normally
; associated with the constant value
dum = gsn_add_polygon(wks,plot,(/xmin,xmax,xmax,xmin,xmin/), \
(/ymin,ymin,ymax,ymax,ymin/),gsres)
draw(plot) ; Now draw plot and
frame(wks) ; advance frame.
else
; Not a constant field.
plot = gsn_csm_contour(wks,z,res)
end if
end
--Mary
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jun 22 2007 - 14:03:33 MDT
This archive was generated by hypermail 2.2.0 : Sun Jun 24 2007 - 19:42:21 MDT