[ncl-talk] XY scatter plots and its XY axis marker is in the form of index

Karin Meier-Fleischer meier-fleischer at dkrz.de
Fri Apr 8 07:03:45 MDT 2016


Hi Grace,

do you mean how to plot a legend at the lower right box edge of the 
scatter plot containing the marker and data labels?

Here is an example how to create a scatter plot with a user defined legend:

;---------------------------------------------------
; set_xy_markers.ncl
;---------------------------------------------------
begin

   npts    =  100
   data1   =  random_uniform(0.1,50,npts)
   data2   =  random_uniform(0.1,50,npts)
   x       =  ispan(1,npts,1)

   print("min/max data = " + min(data1) + "/" + max(data1))
   print("min/max data = " + min(data2) + "/" + max(data2))

;-- create data array containing data1 and data2
   data = new((/2,npts/),typeof(data1))
   data(0,:) =  data1
   data(1,:) =  data2

;-- set explicit labels for legend
   labels = (/"data 1","data 2"/)

;-- open workstation
   wks = gsn_open_wks("x11","plot_xy_markers")

;-- set resources
   res                        =  True
   res at gsnMaximize            =  True ;-- maximize plot output

   res at tiMainString           = "Marker Plot" ;-- add title

   res at trYMinF                =  min(data1)-20. ;-- y-axis minimum to 
have enough space for legend
   res at trYMaxF                =  max(data1)+20. ;-- y-axis maximum

   res at tmLabelAutoStride      =  True ;-- use nice tick mark labels

   res at xyMarkLineModes        = (/"Markers","Markers"/) ;-- set mark 
line mode for both variables
   res at xyMarkers              = (/ 10, 16/) ;-- choose marker types
   res at xyMarkerColors         = (/"red","blue"/) ;-- choose marker colors

   res at lgJustification        = "TopRight" ;-- position of legend
   res at lgLabelFontHeightF     =  0.01 ;-- legend label font size
   res at lgItemOrder            = (/1,0/) ;-- reverse the legend
   res at xyExplicitLabels       =  labels ;-- use explicit legend labels

   res at pmLegendDisplayMode    = "Always" ;-- display legend always
   res at pmLegendWidthF         =  0.10 ;-- legend width
   res at pmLegendHeightF        =  0.08 ;-- legend height
   res at pmLegendOrthogonalPosF = -0.24 ;-- move legend up
   res at pmLegendParallelPosF   =  0.98 ;-- move legend right

;-- create the plot
   plot = gsn_csm_xy(wks,x,data,res)

end
;------------------------------------------------


Bye,
Karin

Am 08.04.16 um 11:34 schrieb grace:
> Hi all:
>    I am trying to plot XY scatter plots and its XY axis marker is in 
> the form of index,just like the plot below. ‍
>>>    How can I plot a picture like it?
> Any information will be appreciated.
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160408/ca541f31/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 26305 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160408/ca541f31/attachment.png 


More information about the ncl-talk mailing list