Beispiel #1
0
#  Get the polygon data and fill polygons with random colors in 
#  the range of our color table (2-31).
#
for st in xrange(npoly):
  for cd in xrange(ncds[st]):
    rand_num = int(29.*random.random()+2.)
    if (st == 42 and cd == 0):          # save value
      va1_rn = rand_num                 # VA clim div 1
    if (st == 42 and cd == 6):          # use value for
      res_poly.gsFillColor = va1_rn     # VA clim div 1
    else:
      res_poly.gsFillColor = rand_num
    varstr = statenames[st]+"_CD" + str(cd+1)
    x = ncdf.variables[varstr].lon
    y = ncdf.variables[varstr].lat
    Ngl.polygon (wks,plot,x,y,res_poly)
    del(varstr)
    del(x)
    del(y)

#
# Add a title.
#
res_txt               = Ngl.Resources()         # text resources
res_txt.txFontHeightF = 0.03                    # select font size
res_txt.txFont        = "helvetica-bold"        # font
Ngl.text_ndc (wks, "Climate Division Polygons", 0.5, 0.78, res_txt)

Ngl.frame(wks)

Ngl.end()
Beispiel #2
0
Datei: map2.py Projekt: yyr/pyngl
gsres.gsLineColor            = "black"
gsres.gsLineThicknessF       = 2.0
gsres.gsLineLabelFont        = "helvetica-bold"
gsres.gsLineLabelFontHeightF = 0.02
gsres.gsLineLabelFontColor   = "black"
gsres.gsFillIndex            = 0
gsres.gsEdgesOn              = False

# Tropical zone

gsres.gsFillColor = 87

px = [360.,360.,0.,0.,360.]
py = [-23.5,23.5,23.5,-23.5,-23.5]

Ngl.polygon(wks,map,px,py,gsres)

# North and South temperate zones.

gsres.gsFillColor = 135

py[0:5] = [ 23.5 , 66.5 , 66.5 , 23.5 , 23.5]
px[0:5] = [ 360. , 360. , 0. , 0. , 360.]
Ngl.polygon(wks,map,px,py,gsres)

py[0:5] = [ -23.5 , -66.5 , -66.5 , -23.5 , -23.5 ]
Ngl.polygon(wks,map,px,py,gsres)

# Frigid zones.

gsres.gsFillColor = 167
Beispiel #3
0
  
res.tiMainString          = "Estimated Cancer Deaths for 2002"

res.nglFrame              = False          # Don't advance frame.

ymin = 0.                                # For bar plot.
dx   = min(x[1:-1]-x[0:-2])              # Distance between X values.

gsres = Ngl.Resources()                  # Resource list for bars.
# Loop through each Y point, and create and draw a bar for it.
for i in xrange(len(y)):
  xbar,ybar = get_bar(x[i],y[i],dx,ymin)
  plot = Ngl.xy(wks,xbar,ybar,res)

  gsres.gsFillColor = colors[i+2]         # Set color for bar.
  Ngl.polygon(wks,plot,xbar,ybar,gsres)   # Fill the bar.
  Ngl.polyline(wks,plot,xbar,ybar)        # Outline the bar.
  
# Set up info for box.
width  = 0.07          # Box width
height = 0.05          # Box height

# Set coordinates for top left corner of the eight boxes.
xpos   = [0.20,0.40,0.60,0.80,0.20, 0.40, 0.60, 0.80]
ypos   = [0.13,0.13,0.13,0.13,0.055,0.055,0.055,0.055]

# Text resources.
txres               = Ngl.Resources()
txres.txFontHeightF = 0.015              # Decrease size of font
txres.txJust        = "CenterLeft"       # Left justify
Beispiel #4
0
xyplot = Ngl.xy(wks,xarr,yarr,sres)    # Draw XY plot

# Set up resource list to add markers to XY plot.
polyres                   = Ngl.Resources()
polyres.gsMarkerIndex     = 16           # polymarker style
polyres.gsMarkerSizeF     = 10.          # polymarker size
        
# Add some gray-filled boxes.
dum2 = []
        
resp = Ngl.Resources()
resp.gsFillColor = "Gray75"
xpts = [0.,0.,8.,8.,0.]
ypts = [17.1,18.9,18.9,17.1,17.1]
Ngl.polygon (wks,xyplot,xpts,ypts,resp)
ypts = [11.,7.,7.,11.,11.]
Ngl.polygon (wks,xyplot,xpts,ypts,resp)
ypts = [25.7,31.8,31.8,25.7,25.7]
Ngl.polygon (wks,xyplot,xpts,ypts,resp)

# Add 3 sets markers to XY plot.

# 1st set
xcoord = [3.12,3.69, 4.54,5.12,3.35]
ycoord = [2.41,7.42,10.84,9.67,7.03]
polyres.gsMarkerColor = "blue"
for gg in range(5):
  Ngl.polymarker(wks,xyplot,xcoord[gg],ycoord[gg],polyres)

# 2nd set
Beispiel #5
0
#  Get the polygon data and fill polygons with random colors in
#  the range of our color table (2-31).
#
for st in range(npoly):
    for cd in range(ncds[st]):
        rand_num = int(29. * random.random() + 2.)
        if (st == 42 and cd == 0):  # save value
            va1_rn = rand_num  # VA clim div 1
        if (st == 42 and cd == 6):  # use value for
            res_poly.gsFillColor = cmap[va1_rn, :]  # VA clim div 1
        else:
            res_poly.gsFillColor = cmap[rand_num, :]
        varstr = "{}_CD{}".format(statenames[st], cd + 1)
        x = ncdf.variables[varstr].lon
        y = ncdf.variables[varstr].lat
        Ngl.polygon(wks, plot, x, y, res_poly)
        del (varstr)
        del (x)
        del (y)

#
# Add a title.
#
res_txt = Ngl.Resources()  # text resources
res_txt.txFontHeightF = 0.03  # select font size
res_txt.txFont = "helvetica-bold"  # font
Ngl.text_ndc(wks, "Climate Division Polygons", 0.5, 0.78, res_txt)

Ngl.frame(wks)

Ngl.end()
Beispiel #6
0
gsres.gsLineColor = "black"
gsres.gsLineThicknessF = 2.0
gsres.gsLineLabelFont = "helvetica-bold"
gsres.gsLineLabelFontHeightF = 0.02
gsres.gsLineLabelFontColor = "black"
gsres.gsFillIndex = 0
gsres.gsEdgesOn = False

# Tropical zone

gsres.gsFillColor = 87

px = [360., 360., 0., 0., 360.]
py = [-23.5, 23.5, 23.5, -23.5, -23.5]

Ngl.polygon(wks, map, px, py, gsres)

# North and South temperate zones.

gsres.gsFillColor = 135

py[0:5] = [23.5, 66.5, 66.5, 23.5, 23.5]
px[0:5] = [360., 360., 0., 0., 360.]
Ngl.polygon(wks, map, px, py, gsres)

py[0:5] = [-23.5, -66.5, -66.5, -23.5, -23.5]
Ngl.polygon(wks, map, px, py, gsres)

# Frigid zones.

gsres.gsFillColor = 167
Beispiel #7
0
xyplot = Ngl.xy(wks, xarr, yarr, sres)  # Draw XY plot

# Set up resource list to add markers to XY plot.
polyres = Ngl.Resources()
polyres.gsMarkerIndex = 16  # polymarker style
polyres.gsMarkerSizeF = 10.  # polymarker size

# Add some gray-filled boxes.
dum2 = []

resp = Ngl.Resources()
resp.gsFillColor = "Gray75"
xpts = [0., 0., 8., 8., 0.]
ypts = [17.1, 18.9, 18.9, 17.1, 17.1]
Ngl.polygon(wks, xyplot, xpts, ypts, resp)
ypts = [11., 7., 7., 11., 11.]
Ngl.polygon(wks, xyplot, xpts, ypts, resp)
ypts = [25.7, 31.8, 31.8, 25.7, 25.7]
Ngl.polygon(wks, xyplot, xpts, ypts, resp)

# Add 3 sets markers to XY plot.

# 1st set
xcoord = [3.12, 3.69, 4.54, 5.12, 3.35]
ycoord = [2.41, 7.42, 10.84, 9.67, 7.03]
polyres.gsMarkerColor = "blue"
for gg in range(5):
    Ngl.polymarker(wks, xyplot, xcoord[gg], ycoord[gg], polyres)

# 2nd set
res = Ngl.Resources()  #-- generate an res object for plot
res.nglFrame = False  #-- don't advance frame
res.nglPointTickmarksOutward = True  #-- point tickmarks outward

res.tiXAxisString = "x-values"  #-- x-axis title
res.tiYAxisString = "y-values"  #-- y-axis title

res.tmXBMode = "Explicit"  #-- define bottom x-axis values and labels
res.tmXBValues = x  #-- x-axis values
res.tmXBLabels = xlabels  #-- x-axis labels
res.tmXBLabelFontHeightF = 0.012  #-- bottom x-axis font size

res.trXMinF = 0.0  #-- x-axis min value
res.trXMaxF = 13.0  #-- x-axis max value
res.trYMinF = 0.0  #-- y-axis min value
res.trYMaxF = 12.0  #-- y-axis max value

#-- bar resources
barres = Ngl.Resources()  #-- resource list for bars
barres.gsFillColor = color  #-- set bar color

#-- loop through each y point and create bar
for i in range(len(y)):
    xbar, ybar = get_bar(x[i], y[i], dx, res.trXMinF, 0.3)
    plot = Ngl.xy(wks, xbar, ybar, res)
    Ngl.polygon(wks, plot, xbar, ybar, barres)  #-- filled bar

Ngl.frame(wks)  #-- advance frame

Ngl.end()
Beispiel #9
0
res.tiMainString = "Estimated Cancer Deaths for 2002"

res.nglFrame = False  # Don't advance frame.

ymin = 0.  # For bar plot.
dx = min(x[1:-1] - x[0:-2])  # Distance between X values.

gsres = Ngl.Resources()  # Resource list for bars.
# Loop through each Y point, and create and draw a bar for it.
for i in xrange(len(y)):
    xbar, ybar = get_bar(x[i], y[i], dx, ymin)
    plot = Ngl.xy(wks, xbar, ybar, res)

    gsres.gsFillColor = colors[i + 2]  # Set color for bar.
    Ngl.polygon(wks, plot, xbar, ybar, gsres)  # Fill the bar.
    Ngl.polyline(wks, plot, xbar, ybar)  # Outline the bar.

# Set up info for box.
width = 0.07  # Box width
height = 0.05  # Box height

# Set coordinates for top left corner of the eight boxes.
xpos = [0.20, 0.40, 0.60, 0.80, 0.20, 0.40, 0.60, 0.80]
ypos = [0.13, 0.13, 0.13, 0.13, 0.055, 0.055, 0.055, 0.055]

# Text resources.
txres = Ngl.Resources()
txres.txFontHeightF = 0.015  # Decrease size of font
txres.txJust = "CenterLeft"  # Left justify