1 2DIM
   Syntax: 2DIM option[/qual] id [&idb] [par1 par2 ...]
   where: option  is the 2-dimensional histogram plotting mode.
          id      is the histogram identifier
          idb     is the (optional) secondary identifier
          par     are any parameters

  Interface to the HIGZ IGTABL routines for plotting 2-dimensional
  histograms in different ways.  This command is an alias for
  `HISTOGRAM 2DIM'. The `2DIM' command is useful if you want to change
  the parameters on the command line.
  Use the command `HISTOGRAM IGTABLE' or `IGTABLE' if you have
  specified the option and any relevant parameters with the
  `SET IGTABLE' command. The `SET IGTABLE' and `IGTABLE' commands are
  useful if you want to make many plots with the same parameters.

  The following options are available:
    ARROW       Arrows with magnitude and direction proportional to
                rate of change.
    BOX         Boxes with area proportional to the number of entries.
    CHAR        Number of letter with number of entries.
    COLOUR      Colour plot.
    CONTOUR     Contour plot joining points with equal values.
    SCATTER     Scatter plot.
    TEXT        Number of entries drawn in each bin.
    LEGO        Lego plot with different styles.
    SURFACE     Surface plot with different styles.

  For `LEGO' and `SURFACE' plot additional qualifiers can be given
  that specify the coordinate system to be used and the style of the
  plot. The possible coordinate systems are:
    POL         Polar coordinates,
    CYL         Cylindrical coordinates,
    SPH         Spherical coordinates,
    PSD         Pseudo-rapidity coordindates.

  Some of the options allow qualifiers which further control the style.
  See the `LEGO' and `SURFACE' subtopics for the other options on
  colour and shading which only apply to such plots. Fine control of
  the contours is also possible. If you want to make a contour plot
  with solid colours you can use the `SURFACE/C2' command.

  There are also a number of options available for drawing 2-dimensional
  histograms using the normal `PLOT' command and setting the
  appropriate symbol number. See HELP SET SYMBOL for more details.

  The normal procedure is to `FETCH' the histograms from a file and
  then plot them using the above syntax.  You can also plot histograms
  directly from an HBOOK RZ file by opening the file (`OPEN' or
  `HB_OPEN') and then giving the plot command. This feature can be
  suppressed using the `SET AUTOFETCH OFF' command. Note that this
  only works for single histograms and not for a range nor for all
  histograms.

2 ARROW
  Syntax:  2DIM ARROW id[&idb]

  Draws a 2-D histogram with an arrow for each bin. The size and
  magnitude of the arrow show the slope from each bin to its neighbour.

  An alternative syntax is:
    SET IGTABLE ARROW
    IGTABLE id[&idb]

2 BOX
  Syntax:  2DIM BOX id[&idb]

  Draws a 2-D histogram with a box for each bin, the area of which is
  proportional to the number of entries.

  An alternative syntax is:
    SET IGTABLE BOX
    IGTABLE id[&idb]

2 CHAR
  Syntax:  2DIM CHAR id[&idb]

  Draws a 2-D histogram with the a number or letter for the number of
  entries given for each bin. The font is set using the
  `SET FONT SYMBOL' command.

  An alternative syntax is:
    SET IGTABLE CHAR
    IGTABLE id[&idb]

2 COLOUR
  Syntax:  2DIM COLOUR[/qual] id[&idb] mode
  where:   qual     Z means show the colour scale
                   NZ means do not show the colour scale (default)
           mode     0 means uses the standard 8 colours

  Draws a 2-D histogram with colours for the number of entries. By
  default the scale is not given on the right-hand side. Use the qualifier
  `/Z' to turn the scale on.

  You can change the size of the font on the colour scale using the command
  `SET Z SCALE = = size'.

  An alternative syntax is:
    SET IGTABLE COLOUR
    IGTABLE id[&idb]

  With this syntax the colour scale is not shown.

2 CONTOUR
  Syntax:  2DIM CONTOUR id[&idb] nlevel mode [level1 level2 ...]
  where:   nlevel   is the number of levels to show.
           mode     is the mode to use:
                    0     = Use colour to distinguish the contours
                    1.nnn = Use the lines type with colour n
                    2.nnn = Use the same line type and colour for all
                            contours
           level1   is the z-value for the contour
  Default: nlevel=20, mode=0

  Draws a 2-D histogram as a contour plot. To use the default number
  of levels give `nlevel' as 0. Different modes are available to
  distinguish between the contour lines. The numbers of the colours
  are the same as for the `SET COLOUR' command. Note that you have to
  give the full 3 digits for the colour, e.g. 1.004, to use the line
  type and draw the contour in blue. You can set the line type used
  for the contours with mode 2.nnn by using the command
  `SET HIGZ LTYP n'.

  An alternative syntax is:
    SET IGTABLE CONTOUR nlevel mode [level1 level2 ...]
    IGTABLE id[&idb]

  Use the `2DIM SURFACE/C2' command to make a contour plot with solid
  colours. See the examples for how this is done.

2 LEGO
  Syntax:  2DIM LEGO[/qual] id[&idb] theta phi [ncol1 ncol2 ncol3 ...]
  where:   qual      describes the style of the lego plot
           theta     is the theta viewing angle
           phi       is the phi viewing angle
           ncol1...  are the colours to use for the colour options
  Default: theta=30, phi=30

  Draws a LEGO plot. An alternative syntax is `LEGO/IGTABLE[/qual]'.

  The possible qualifiers and their equivalent `SET IGTABLE' commands are:
    /C1    LEGOC1   Colour lego plot - mode 1.
    /C2    LEGOC2   Colour lego plot - mode 2 (most common).
    /BAR   LEGOBAR  Reduced the bin width plot. Use the commands
                    `SET HIGZ BARW frac' and `SET HIGZ BARO frac' to
                    adjust the bin width and offset.
    /POL   LEGOPOL  LEGO plot in polar coordinates.
    /CYL   LEGOCYL  LEGO plot in cylindrical coordinates.
    /SPH   LEGOSPH  LEGO plot in spherical coordinates.
    /PSD   LEGOPSD  LEGO plot in pseudo-rapidity coordinates.
    /NFB            Do not draw the front box.
    /NBB            Do not draw the back box.

  One of the options `C1,C2,BAR' can be combined with one of the
  coordinate system options.

  While any angles can be specified for theta and phi, theta between 0
  and 90 degrees works best. If you want to look at the bottom of your
  surface, use a theta angle between 90 and 180 degrees.

  You can specify your own colour scheme by giving the colour
  numbers. Use the `SET COLOUR REPRESENT ncol r g b colname' command to
  define new colours or redefine existing ones.

2 SCATTER
  Syntax:  2DIM SCATTER id[&idb] marker maxpnt
  where:   marker   is the marker type to use
           maxpnt   is the maximum number of random points in a cell

  Draws a 2-D histogram with random points per bin, where the number
  of points is proportional to the number of entries.

  An alternative syntax is:
    SET IGTABLE SCATTER
    IGTABLE id[&idb]


2 SURFACE
  Syntax:  2DIM SURFACE[/qual] id[&idb] theta phi [ncol1 ncol2 ncol3 ...]
  where:   qual     describes the style of the surface plot
           theta    is the theta viewing angle
           phi      is the phi viewing angle
           ncol1...  are the colours to use for the colour options
  Default: theta=30, phi=30

  Draws a SURFACE plot. An alternative syntax is `SURFACE/IGTABLE[/qual]'.

  The possible qualifiers and their equivalent `SET IGTABLE' commands are:
    /C1    SURFC1    Surface plot with colours and contour lines.
    /C2    SURFC2    Surface plot with colours only.
    /CONT  SURFCONT  Surface plot with colour contour plot on top.
    /SHADE SURFSHADE Surface plot with shading.
    /POL   SURFPOL   Surface plot in polar coordinates.
    /CYL   SURFCYL   Surface plot in cylindrical coordinates.
    /SPH   SURFSPH   Surface plot in spherical coordinates.
    /PSD   SURFPSD   Surface plot in pseudo-rapidity coordinates.
    /NFB             Do not draw the front box.
    /NBB             Do not draw the back box.

  One of the options `C1,C2,CONT,SHADE' can be combined with one of the
  coordinate system options.

  The `2DIM SURFACE/C2 id 90 0' command can be used to draw a contour
  with solid colours. You can control the values for each colour by
  specifying the `Z LIMIT' and then giving a corresponding number of
  colours on the command line. See the examples for how this is done.

  While any angles can be specified for theta and phi, theta between 0
  and 90 degrees works best. If you want to look at the bottom of your
  surface, use a theta angle between 90 and 180 degrees.

  You can specify your own colour scheme by giving the colour
  numbers. Use the `SET COLOUR REPRESENT ncol r g b colname' command
  to define new colours or redefine existing ones.

2 TEXT
  Syntax:  2DIM TEXT id[&idb]

  Draws a 2-D histogram with the number of entries given for each
  bin. The font is set using the `SET FONT SYMBOL' command.

  An alternative syntax is:
    SET IGTABLE TEXT
    IGTABLE id[&idb]


2 Examples

!\begin{enumerate}
!\item
!^
  Example 1:
    Make a lego plot of 2-D histogram 10:
      2dim lego 10 30 30
      ! Use colour option 2
      lego/c2   10 30 30

!\item
!^
  Example 2:
    Make a contour plot with contours at 1,4 and 9:
      ! Take default parameters
      2dim contour 10 0
      ! 2dim command with parameters on the command line
      2dim contour 10 3 1 1 4 9
      ! Using the set igtable command for plots 10 and 11
      set igtable contour 10 3 1 1 4 9
      igtable 10
      igtable 11

!\item
!^
  Example 3:
    Make a contour plot with solid colours using the SURFACE
    command. Note that the scale is not drawn properly here:
      ! Default colours
      2dim surface/c2/nfb/nbb 10 90 0
      ! Specify my own colours
      ! Violet
      set col rep 8 0.60 0.0 0.9 violet
      ! Orange
      set col rep 9 1.0 0.5 0.0 orange
      ! Set limit as 0 to 10 and specify the 10 colours
      ! The standard colours are:
      ! 1 black
      ! 2 red
      ! 3 green
      ! 4 blue
      ! 5 yellow
      ! 6 magenta
      ! 7 cyan
      set z lim 0 10
      2dim surface/c2/nfb/nbb 10 90 0 7 7 7 9 8 4 3 2 1 7

!\item
!^
  Example 4:
    Make a contour plot with solid colours using the SURFACE
    command. Draw the frame at the centre of the first bin rather than
    the edge, so that the whole plot is filled. Note that you could also
    plot the 2-D Gaussian using `FUNCTION PLOT', rather than fitting
    it, as is done here. This example also shows
    how to use the registers containing the number of bins and the bin
    boundaries as well as those containing the corners of the plot:
      fet $MN_FIT/help/tutorial/hbook_example.his 10
      !
      ! Make a nice Gaussian by fitting the data
      !
      fun del 0
      fun add 2dim sig
      1000
      0
      0
      1
      1
      fit/like 10
      mini
      display
      exit
      ! Define some new colours
      ! Violet
      set col rep 8 0.60 0.0 0.9 violet
      ! Orange
      set col rep 9 1.0 0.5 0.0 orange
      !
      ! Draw the Gaussian without any frame
      !
      set frame all off
      ! Set the z limit and give the 10 colours
      set z lim 0 10
      ! The 2-D Gaussian is in plot 10&981
      2d surface/c2/nbb/nfb 10&981 90 0 7 7 7 9 8 4 3 2 1 7
      !
      ! Move the scale and frame half a bin inside the plot
      !
      ! Plot coordinates - these are set with the set plot default command
      ! Use the bin boundaries and the number of bins
      set plot 10&981 default
      dep r01 = r205 + 0.5*(r133-r132)/r131
      dep r02 = r206 - 0.5*(r133-r132)/r131
      dep r03 = r207 + 0.5*(r138-r137)/r136
      dep r04 = r208 - 0.5*(r138-r137)/r136
      dep r05 = r02 - r01
      dep r06 = r04 - r03
      !
      ! In cm - these are only set once the histogram has been plotted
      dep r11 = r201 + 0.5*(r202-r201)/r131
      dep r12 = r202 - 0.5*(r202-r201)/r131
      dep r13 = r203 + 0.5*(r204-r203)/r136
      dep r14 = r204 - 0.5*(r204-r203)/r136
      dep r15 = r12 - r11
      dep r16 = r14 - r13
      dep r17 = r11 - r201
      dep r18 = r13 - r203
      !
      ! The number of bins is effectively reduced by 1
      dep r21 = r131 - 1
      dep r22 = r134 - 1
      book/bin/noerr 9999 'Frame' 2 r21 r01 r02 r22 r03 r04
      set x lim r01 r02
      set y lim r03 r04
      !
      ! Move the frame in by half a bin and make it one bin smaller
      set x wmarg r17
      set y wmarg r18
      set x wsize r15
      set y wsize r16
      !
      ! Draw the frame
      !
      set frame all on
      set title off
      plot/noclear/empty 9999

!\end{enumerate}

