NCL Home > Documentation > Graphics > Graphical Interfaces

gsn_open_wks

Opens a workstation on which to draw graphics.

Prototype

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

	function gsn_open_wks (
		type [1] : string,  
		name [1] : string   
	)

	return_val [1] :  graphic

Arguments

type

The type of workstation to open.

name

The name of the workstation.

Return value

A scalar id of the workstation is returned.

Description

This function creates a workstation for drawing graphics, given a workstation type and name.

A workstation type can be an NCGM file ("ncgm"), a PostScript file ("ps", "eps", or "epsi"), a PDF file ("pdf"), or an X11 window ("x11"). The name will be used for the ouput file (if applicable) and with the appropriate extension appended.

In addition, if a resource file name.res exists, it will be loaded. name can have a directory path as part of its string, if the resource file you want to load is in a separate directory from where the NCL script resides.

The default color map associated with a workstation is "hlu_default". If you want to change this, you can:

  1. Set an attribute of type called wkColorMap to one of the other predefined color maps.
  2. Create your own.
  3. Permanently change the default color map that is used by setting one in your .hluresfile file.

If you don't have gsnMaximize set to True (for when you draw your plots), then by default, all output going to a PS or PDF file will be in "portrait" mode. To change this to "landscape" mode, do the following:

   wks_type = "ps"        ; or "pdf"
   wks_type@wkOrientation = "landscape"
   wks = gsn_open_wks(wks_type,"example")

You can have up to fifteen PostScript workstations open at one time, but you can only have one NCGM or PDF workstation open at one time.

See Also

gsn_define_colormap, clear, update, frame, NhlUpdateWorkstation, NhlChangeWorkstation

Examples

Try the following script with the resource files zero.res, one.res, two.res, three.res, and four.res in the same directory. Also, try running this script without the resource files to see the difference:

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

begin
  xwks    = gsn_open_wks("x11", "zero")
  ps1wks  = gsn_open_wks("ps",  "one")
  ps2wks  = gsn_open_wks("ps",  "two")
  pdfwks  = gsn_open_wks("pdf", "three")
  ncgmwks = gsn_open_wks("ncgm","four")

  gsn_text_ndc(xwks,   "X workstation",0.5,0.5,False)
  gsn_text_ndc(ps1wks, "PS 1 workstation",0.5,0.5,False)
  gsn_text_ndc(ps2wks, "PS 2 workstation",0.5,0.5,False)
  gsn_text_ndc(pdfwks, "PDF workstation",0.5,0.5,False)
  gsn_text_ndc(ncgmwks,"NCGM workstation",0.5,0.5,False)

  frame(xwks)
  frame(ps1wks)
  frame(ps2wks)
  frame(pdfwks)
  frame(ncgmwks)
end

For some other application examples, see: