[ncl-talk] xy-plot with markers (depending on a 3. variable)

Anna Lena Bittner anna at hbittnersth.de
Thu Jul 9 10:25:22 MDT 2015


Hi,

I would like to create a xy-plot with markers. The markers should have 
different colors. The colors should be controlled by a 3. variable.
In my plot I already created the makers, but I don't know how to define 
the color with a 3. variable ( in my case the variable t).
I couldn't find a description for this kind of plot. If there is a 
description on the homepage let me know.

I have attached my scripts here.


Thanks a lot for your help.

Anna Lena
-------------- next part --------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin
;************************************************
; read in data
;************************************************

    filename1 = "/home/bittner/Uni/Masterarbeit/Programme/Ausgaben/Agent_2.txt"



   data1 = asciiread(filename1,(/124,5/),"float")

;************************************************
; to plot multiple lines, you must put them into
; a mulidimensional array
;************************************************



   x_1     = new((/124/),float,0)
   y_1     = new((/124/),float,0)
   x_2     = new((/124/),float,0)
   y_2     = new((/124/),float,0)
   x_3     = new((/124/),float,0)
   y_3     = new((/124/),float,0)
   t       = new((/124/),float)

  ;;uv     = new((/2,251/),float)
  ;;t      = new((/1,251/),float)

;;************************************************
;;Deklaration des Datenfelds
;;***********************************************



  x_1 = data1(:,1)
  y_1 = data1(:,2)
 x_2 = data1(:,3)
 y_2 = data1(:,4)
;  x_3 = data1(:,5)
;  y_3 = data1(:,6)
  t = data1(:,0)

x = new((/2,124/),float,0)
   x (0,:) = x_1
   x (1,:) = x_2
;   x (2,:) = x_3

y= new((/2,124/),float,0)
   y (0,:) = y_1
   y (1,:) = y_2
;   y (2,:) = y_3
  ;z      = data1(:,0)



;;************************************************
;;Ressourcen
;;************************************************

  wks   = gsn_open_wks ("pdf","/home/bittner/Uni/Masterarbeit/Programme/Ausgaben/Agent_2")                  ; open ps file

  gsn_define_colormap(wks,"BkBlAqGrYeOrReViWh200")


  res                        = True                       ; plot mods desired
        res at gsnDraw           = False                 ; don't draw
        res at gsnFrame          = False

;Ränder des Gitters festlegen    
        res at trXMinF             = 0
        res at trXMaxF             = 50
        res at trYMinF             = 0
        res at trYMaxF             = 50






;Beschriftung
  res at tiMainString           =                 "Weg dreier Agenten"
 res at xyLineColors            =          (/90,40/)     ; Set the line colors.
 res at xyLineThicknesses = (/1.0/)
 




;Gitternetz
  res at tmXMajorGrid      = True
  res at tmXMinorGrid      = True
  res at tmXMajorGridLineColor = 6
  res at tmXMinorGridLineColor = 9
  res at tmXMajorGridLineDashPattern = 1
  res at tmXMinorGridLineDashPattern = 1
  res at tmXMajorGridThicknessF = 1.5
  res at tmYMajorGrid      = True
  res at tmYMajorGridLineColor = 6
  res at tmYMajorGridLineDashPattern = 1
  res at tmYMajorGridThicknessF = 1.5

;Maker
 res at xyDashPattern = 0               ; Make curves all solid
 res at xyMarkLineMode = "MarkLines"    ; Markers *and* lines
 res at xyMarkers      = (/6,11/)    ; 3 different markers
 res at xyMarkerColors = (/"green","blue"/)  ; 3 different colors


;;Make Legend
  res at pmLegendOrthogonalPosF = -1.05
  res at pmLegendParallelPosF   = 1.15
  res at pmLegendDisplayMode    = "Always"
  res at pmLegendWidthF         = 0.1
  res at pmLegendHeightF        = 0.1
   res at lgAutoManage           =False
   res at lgLabelFontHeightF     = 0.01
  res at xyExplicitLegendLabels = (/"Agent 1", "Agent 2"/)

  plot1  = gsn_csm_xy (wks,x,y,res) 


draw(plot1)

 frame(wks)
end


More information about the ncl-talk mailing list