Re: color-coded scatter plot

From: Mary Haley (haley AT ucar.edu)
Date: Tue Dec 07 2004 - 16:50:08 MST

  • Next message: Sylvia Murphy: "Re: NCL to html routine"

    On Tue, 7 Dec 2004, Yee Lau wrote:

    > Hello,
    >
    > I have a huge dataset with random points of lon, lat and temperature values
    > (500,000).
    > I need to draw these on a map with the temperature being color-coded. I know
    > how
    > to create colormap and draw the points one by one using gsn_polymarker. I
    > would like
    > to know if there's any other way to draw the color-coded points using NCL
    > which will
    > speed up this process.
    >
    > Thanks for any info
    > Yee

    Hi Yee,

    There is not really an easy way to do this in NCL. You can first
    generate individual XY plots for each set of points that
    you want to be represented by one color, and then overlay these on
    a map. Below is an example where I've generated some dummy data
    using "random_uniform", created two XY plots, one with red markers
    and one with blue markers, and then I've overlaid both of these
    on cylindrical equidistant map.

    --Mary

    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

    begin

    ;
    ; Generate dummy data.
    ;
       lat1 = random_uniform(-90.,90.,100)
       lon1 = random_uniform(-180.,180.,100)
       lat2 = random_uniform(-90.,90.,100)
       lon2 = random_uniform(-180.,180.,100)

       T = random_uniform(0.,80.,100)
       wks = gsn_open_wks("x11","example")

       res = True
       res@gsnDraw = False
       res@gsnFrame = False

       map = gsn_csm_map(wks,res) ; Create a map; don't draw it yet.

       res@xyMarker = 16
       res@xyMarkLineMode = "Markers"
       res@xyMarkerColor = "red"

       xy1 = gsn_xy(wks,lon1,lat1,res) ; Create first XY plot.

       res@xyMarkerColor = "blue"
       xy2 = gsn_xy(wks,lon2,lat2,res) ; Create second XY plot.

       overlay(map,xy1) ; Overlay both XY plots on map.
       overlay(map,xy2)

       draw(map) ; Draw map.
       frame(wks) ; Advance frame.

    end

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Tue Dec 07 2004 - 16:53:27 MST