[ncl-talk] String in x axis (XY plot)

Karin Meier-Fleischer meier-fleischer at dkrz.de
Tue Feb 10 05:00:46 MST 2015


Hi John,

You can't use your date variable in the gsn_csm_xy function call because 
date
is of type string, not numeric.
You have to set explicit values and levels for the bottom x-axis like below

   xvalues = ispan(1,dimsizes(date),1)

   res at tmXBMode              = "Explicit"            ;-- y-axis draw mode
   res at tmXBValues            = *xvalues*      ;-- use pre-defined values
   res at tmXBLabels            = *date*     ;-- use pre-defined labels
   res at tmXBLabelAngleF       =  50.0
   res at tmXBLabelDeltaF       =   1.5
   res at tmXBLabelFontHeightF  =   0.009
   res at tmXBLabelJust         = "CenterRight"

   plot  = gsn_csm_xy(wks,*xvalues*,data(:,6),res)

Bye,
Karin


Am 10.02.15 um 11:56 schrieb Ioannis Koletsis:
>
> Ooopsss…..
>
> I am so sorry….
>
> Files are included…..
>
> Dear NCL users,
>
> I would like to make a xy plot timeserie….
>
> The values of the sixth column of input.txt file are set in y axis 
> while the time of simulation in x axis…
>
> However, the date (string) of the attached script (line 29) is not 
> appeared in x axis…..
>
> Is this possible?
>
> Any help would be appreciated…
>
> Best Regards
>
> John
>
> *From:*ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] 
> *On Behalf Of *Karin Meier-Fleischer
> *Sent:* Tuesday, February 10, 2015 12:44 PM
> *To:* ncl-talk at ucar.edu
> *Subject:* Re: [ncl-talk] String in x axis (XY plot)
>
> I can't see an attachment in your mail.
>
> Am 10.02.15 um 11:37 schrieb Ioannis Koletsis:
>
>     Dear NCL users,
>
>     I would like to make a xy plot timeserie….
>
>     The values of the sixth column of input.txt file are set in y axis
>     while the time of simulation in x axis…
>
>     However, the date (string) of the attached script (line 29) is not
>     appeared in x axis…..
>
>     Is this possible?
>
>     Any help would be appreciated…
>
>     Best Regards
>
>     John
>
>     ------------------------------------------------------------------------
>
>     <http://www.avast.com/>
>
>     	
>
>     Αυτό το email είναι απαλλαγμένο από ιούς και κακόβουλο λογισμικό,
>     επειδή η προστασία avast! Antivirus <http://www.avast.com/> είναι
>     ενεργή.
>
>
>
>
>
>     _______________________________________________
>
>     ncl-talk mailing list
>
>     List instructions, subscriber options, unsubscribe:
>
>     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> -- 
> Dipl. Geophys. Karin Meier-Fleischer
> Visualization
> Application Support
>   
> Deutsches Klimarechenzentrum GmbH (DKRZ)
> Bundesstrasse 45a - D20146 Hamburg - Germany
>   
> Phone:    +49 (0)40 460094 126
> Fax:      +49 (0)40 460094 270
> E-Mail:meier-fleischer at dkrz.de  <mailto:meier-fleischer at dkrz.de>
> URL:www.dkrz.de  <http://www.dkrz.de>
>   
> Geschäftsführer: Prof. Dr. Thomas Ludwig
> Sitz der Gesellschaft: Hamburg
> Amtsgericht Hamburg HRB 39784
>
>
> ------------------------------------------------------------------------
> <http://www.avast.com/> 	
>
> Αυτό το email είναι απαλλαγμένο από ιούς και κακόβουλο λογισμικό, 
> επειδή η προστασία avast! Antivirus <http://www.avast.com/> είναι ενεργή.
>
>

-- 
Dipl. Geophys. Karin Meier-Fleischer
Visualization
Application Support

Deutsches Klimarechenzentrum GmbH (DKRZ)
Bundesstrasse 45a - D20146 Hamburg - Germany

Phone:    +49 (0)40 460094 126
Fax:      +49 (0)40 460094 270
E-Mail:   meier-fleischer at dkrz.de
URL:      www.dkrz.de

Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150210/2d22fc1e/attachment.html 
-------------- next part --------------

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

 begin

  type = "x11"
; type = "pdf"
; type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"plt_ts")       ; Create a plot workstation


  data = readAsciiTable("input.txt", 7, "integer", 0)   ; read the data file

  res = True
  res at tmXTOn        = True        
  res at xyLineThicknesses = 2        
  res at xyLineColor   =  "blue"    
  res at tiYAxisString = "Title"
  res at tiXAxisString = "Simulation Time"
  res at tiMainString  = "Main Title"

;;;;;;;;;;;;;;;;;;;;;;;
;;; Make x axis ;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;

  date = sprinti("%0.2i",data(:,1))+"/"+sprinti("%0.2i",data(:,2))+" "+sprinti("%0.2i",data(:,4))
;  ndate = dimsizes(date)
;  ind_date = new(ndate,string)
  
;  x1_offset = date(0)
;  x1 = ispan(0,ndate-1,1)
;  x1 = ind_date

;  res at tmXTLabelsOn = True
;  res at tmXTMode = "Explicit"
;  res at tmXTValues = date

;  print(date)
;  print(data(:,6))

  xvalues = ispan(1,dimsizes(date),1)
  
  res at tmXBMode              = "Explicit"            ;-- y-axis draw mode
  res at tmXBValues            =  xvalues          ;-- use pre-defined values
  res at tmXBLabels            =  date          ;-- use pre-defined labels
  res at tmXBLabelAngleF       =  50.
  res at tmXBLabelDeltaF       =   1.5
;  res at tmLabelAutoStride     =  True
  res at tmXBLabelFontHeightF  =   0.009
  res at tmXBLabelJust         = "CenterRight"
  
  plot  = gsn_csm_xy(wks,xvalues,data(:,6),res)    
;  plot  = gsn_csm_xy(wks,date,data(:,6),res)    
                                                   
   
end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plt_ts.png
Type: image/png
Size: 44335 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150210/2d22fc1e/attachment.png 


More information about the ncl-talk mailing list