[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 48. draw

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 48.1 Introduction to draw

`draw` is a Maxima-Gnuplot interface.

There are three main functions to be used at Maxima level: `draw2d`, `draw3d` and `draw`.

Follow this link for more elaborated examples of this package:

http://www.telefonica.net/web2/biomates/maxima/gpdraw

You need Gnuplot 4.2 to run this program.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 48.2 Functions and Variables for draw

Graphic option: xrange

  Default value: `false`

  If `xrange` is `false`, the range for the x coordinate is computed automatically.

  If the user wants a specific interval for x, it must be given as a Maxima list, as in `xrange=[-2, 3]`.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange = [-3,5],
                   explicit(x^2,x,-1,1))$

  See also `yrange` and `zrange`.

Graphic option: yrange

  Default value: `false`

  If `yrange` is `false`, the range for the y coordinate is computed automatically.

  If the user wants a specific interval for y, it must be given as a Maxima list, as in `yrange=[-2, 3]`.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(yrange = [-2,3],
                   explicit(x^2,x,-1,1),
                   xrange = [-3,3])$

  See also `xrange` and `zrange`.

Graphic option: zrange

  Default value: `false`

  If `zrange` is `false`, the range for the z coordinate is computed automatically.

  If the user wants a specific interval for z, it must be given as a Maxima list, as in `zrange=[-2, 3]`.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(yrange = [-3,3],
                   zrange = [-2,5],
                   explicit(x^2+y^2,x,-1,1,y,-1,1),
                   xrange = [-3,3])$

  See also `yrange` and `zrange`.

Graphic option: logx

  Default value: `false`

  If `logx` is `true`, the x axis will be drawn in the logarithmic scale.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(explicit(log(x),x,0.01,5),
                   logx = true)$

  See also `logy` and `logz`.

Graphic option: logy

  Default value: `false`

  If `logy` is `true`, the y axis will be drawn in the logarithmic scale.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(logy = true,
                   explicit(exp(x),x,0,5))$

  See also `logx` and `logz`.

Graphic option: logz

  Default value: `false`

  If `logz` is `true`, the z axis will be drawn in the logarithmic scale.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(logz = true,
                   explicit(exp(u^2+v^2),u,-2,2,v,-2,2))$

  See also `logx` and `logy`.

Graphic option: terminal

  Default value: `screen`

  Selects the terminal to be used by Gnuplot; possible values are: `screen` (default), `png`, `jpg`, `eps`, and `eps_color`.

  Since this is a global graphics option, its position in the scene description does not matter. It can be also used as an argument of function `draw`.

  Examples:

      (%i1) load(draw)$
      (%i2) /* screen terminal (default) */
            draw2d(explicit(x^2,x,-1,1))$
      (%i3) /* png file */
            draw2d(terminal  = 'png,
                   pic_width = 300,
                   explicit(x^2,x,-1,1))$
      (%i4) /* jpg file */
            draw2d(terminal   = 'jpg,
                   pic_width  = 300,
                   pic_height = 300,
                   explicit(x^2,x,-1,1))$
      (%i5) /* eps file */
            draw2d(file_name = "myfile",
                   explicit(x^2,x,-1,1),
                   terminal  = 'eps)$

  See also `file_name`, `pic_width`, and `pic_height`.

Graphic option: grid

  Default value: `false`

  If `grid` is `true`, a grid will be drawn on the xy plane.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(grid = true,
                   explicit(exp(u),u,-2,2))$

Graphic option: title

  Default value: `""` (empty string)

  Option `title` stores a Maxima string with the main title for the scene. By default, no title is written.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(explicit(exp(u),u,-2,2),
                   title = "Exponential function")$

Graphic option: xlabel

  Default value: `""` (empty string)

  Option `xlabel` stores a Maxima string with the label for the x axis. By default, no label is written.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xlabel = "Time",
                   explicit(exp(u),u,-2,2),
                   ylabel = "Population")$

  See also `ylabel`, and `zlabel`.

Graphic option: ylabel

  Default value: `""` (empty string)

  Option `ylabel` stores a Maxima string with the label for the y axis. By default, no label is written.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xlabel = "Time",
                   ylabel = "Population",
                   explicit(exp(u),u,-2,2) )$

  See also `xlabel`, and `zlabel`.

Graphic option: zlabel

  Default value: `""` (empty string)

  Option `zlabel` stores a Maxima string with the label for the z axis. By default, no label is written.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(zlabel = "Z variable",
                   ylabel = "Y variable",
                   explicit(sin(x^2+y^2),x,-2,2,y,-2,2),
                   xlabel = "X variable" )$

  See also `xlabel`, and `ylabel`.

Graphic option: xtics

  Default value: `true`

  If `xtics` is `true`, tics will be written in the x axis.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) /* No tics in the x-axis */
            draw2d(xtics = false,
                   explicit(exp(u),u,-2,2))$

  See also `ytics`, and `ztics`.

Graphic option: ytics

  Default value: `true`

  If `ytics` is `true`, tics will be written in the y axis.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(ytics = false,
                   explicit(exp(u),u,-2,2),
                   xtics = false)$

  See also `xtics`, and `ztics`.

Graphic option: ztics

  Default value: `true`

  If `ztics` is `true`, tics will be written in the z axis.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) /* No tics in the z-axis */
            draw3d(ztics = false,
                   explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$

  See also `xtics`, and `ytics`.

Graphic option: rot_vertical

  Default value: 60

  `rot_vertical` is the angle (in degrees) of vertical rotation (around the x axis) to set the view point in 3d scenes.

  The angle is bounded to the [0, 180] interval.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(rot_vertical = 170,
                   explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$

  See also `rot_horizontal`.

Graphic option: rot_horizontal

  Default value: 30

  `rot_horizontal` is the angle (in degrees) of horizontal rotation (around the z axis) to set the view point in 3d scenes.

  The angle is bounded to the [0, 360] interval.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(rot_vertical = 170,
                   rot_horizontal = 360,
                   explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$

  See also `rot_vertical`.

Graphic option: xy_file

  Default value: `""` (empty string)

  `xy_file` is the name of the file where the coordinates will be saved after clicking with the mouse button and hitting the 'x' key. By default, no coordinates are saved.

  Since this is a global graphics option, its position in the scene description does not matter.

Graphic option: user_preamble

  Default value: `""` (empty string)

  Expert Gnuplot users can make use of this option to fine tune Gnuplot's behaviour by writing settings to be sent before the `plot` or `splot` command.

  The value of this option must be a string or a list of strings (one per line).

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

  The dumb terminal is not supported by package `draw`, but it is possible to set it by making use of option `user_preamble`,

      (%i1) load(draw)$
      (%i2) draw2d(explicit(exp(x)-1,x,-1,1),
                   parametric(cos(u),sin(u),u,0,2*%pi),
                   user_preamble="set terminal dumb")$

Graphic option: file_name

  Default value: `"maxima_out"`

  This is the name of the file where terminals `png`, `jpg`, `eps` and `eps_color` will save the graphic.

  Since this is a global graphics option, its position in the scene description does not matter. It can be also used as an argument of function `draw`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(file_name = "myfile",
                   explicit(x^2,x,-1,1),
                   terminal  = 'png)$

  See also `terminal`, `pic_width`, and `pic_height`.

Graphic option: pic_width

  Default value: 640

  This is the width of the bitmap file generated by terminals `png` and `jpg`.

  Since this is a global graphics option, its position in the scene description does not matter. It can be also used as an argument of function `draw`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(terminal   = 'png,
                   pic_width  = 300,
                   pic_height = 300,
                   explicit(x^2,x,-1,1))$

  See also `terminal`, `file_name`, and `pic_height`.

Graphic option: pic_height

  Default value: 640

  This is the height of the bitmap file generated by terminals `png` and `jpg`.

  Since this is a global graphics option, its position in the scene description does not matter. It can be also used as an argument of function `draw`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(terminal   = 'png,
                   pic_width  = 300,
                   pic_height = 300,
                   explicit(x^2,x,-1,1))$

  See also `terminal`, `file_name`, and `pic_width`.

Graphic option: eps_width

  Default value: 12

  This is the width (measured in cm) of the Postscipt file generated by terminals `eps` and `eps_color`.

  Since this is a global graphics option, its position in the scene description does not matter. It can be also used as an argument of function `draw`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(terminal   = 'eps,
                   eps_width  = 3,
                   eps_height = 3,
                   explicit(x^2,x,-1,1))$

  See also `terminal`, `file_name`, and `eps_height`.

Graphic option: eps_height

  Default value: 8

  This is the height (measured in cm) of the Postscipt file generated by terminals `eps` and `eps_color`.

  Since this is a global graphics option, its position in the scene description does not matter. It can be also used as an argument of function `draw`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(terminal   = 'eps,
                   eps_width  = 3,
                   eps_height = 3,
                   explicit(x^2,x,-1,1))$

  See also `terminal`, `file_name`, and `eps_width`.

Graphic option: axis_bottom

  Default value: `true`

  If `axis_bottom` is `true`, the bottom axis is shown in 2d scenes.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(axis_bottom = false,
                   explicit(x^3,x,-1,1))$

  See also `axis_left`, `axis_top`, `axis_right`, and `axis_3d`.

Graphic option: axis_left

  Default value: `true`

  If `axis_left` is `true`, the left axis is shown in 2d scenes.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(axis_left = false,
                   explicit(x^3,x,-1,1))$

  See also `axis_bottom`, `axis_top`, `axis_right`, and `axis_3d`.

Graphic option: axis_top

  Default value: `true`

  If `axis_top` is `true`, the top axis is shown in 2d scenes.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(axis_top = false,
                   explicit(x^3,x,-1,1))$

  See also `axis_bottom`, `axis_left`, `axis_right`, and `axis_3d`.

Graphic option: axis_right

  Default value: `true`

  If `axis_right` is `true`, the right axis is shown in 2d scenes.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(axis_right = false,
                   explicit(x^3,x,-1,1))$

  See also `axis_bottom`, `axis_left`, `axis_top`, and `axis_3d`.

Graphic option: axis_3d

  Default value: `true`

  If `axis_3d` is `true`, the x, y and z axis are shown in 3d scenes.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(axis_3d = false,
                   explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$

  See also `axis_bottom`, `axis_left`, `axis_top`, and `axis_right` for axis in 2d.

Graphic option: palette

  Default value: `color`

  `palette` indicates how to map the real values of a matrix passed to object `image` onto color components.

  `palette` is a vector of length three with components ranging from -36 to +36; each value is an index for a formula mapping the levels onto red, green and blue colors, respectively:

       0: 0               1: 0.5           2: 1
       3: x               4: x^2           5: x^3
       6: x^4             7: sqrt(x)       8: sqrt(sqrt(x))
       9: sin(90x)       10: cos(90x)     11: |x-0.5|
      12: (2x-1)^2       13: sin(180x)    14: |cos(180x)|
      15: sin(360x)      16: cos(360x)    17: |sin(360x)|
      18: |cos(360x)|    19: |sin(720x)|  20: |cos(720x)|
      21: 3x             22: 3x-1         23: 3x-2
      24: |3x-1|         25: |3x-2|       26: (3x-1)/2
      27: (3x-2)/2       28: |(3x-1)/2|   29: |(3x-2)/2|
      30: x/0.32-0.78125 31: 2*x-0.84     32: 4x;1;-2x+1.84;x/0.08-11.5
      33: |2*x - 0.5|    34: 2*x          35: 2*x - 0.5
      36: 2*x - 1

  negative numbers mean negative colour component.

  `palette = gray` and `palette = color` are short cuts for `palette = [3,3,3]` and `palette = [7,5,15]`, respectively.

  Since this is a global graphics option, its position in the scene description does not matter.

  Examples:

      (%i1) load(draw)$
      (%i2) im: apply(
                 'matrix,
                  makelist(makelist(random(200),i,1,30),i,1,30))$
      (%i3) /* palette = color, default */
            draw2d(image(im,0,0,30,30))$
      (%i4) draw2d(palette = gray, image(im,0,0,30,30))$
      (%i5) draw2d(palette = [15,20,-4],
                   colorbox=false,
                   image(im,0,0,30,30))$

  See also `colorbox`.

Graphic option: colorbox

  Default value: `true`

  If `colorbox` is `true`, a color scale is drawn together with `image` objects.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) im: apply('matrix,
                       makelist(makelist(random(200),i,1,30),i,1,30))$
      (%i3) draw2d(image(im,0,0,30,30))$
      (%i4) draw2d(colorbox=false, image(im,0,0,30,30))$

  See also `palette`.

Graphic option: enhanced3d

  Default value: `false`

  If `enhanced3d` is `true`, surfaces are colored in 3d plots; in other words, it sets Gnuplot's pm3d mode.

  See option `palette` to learn how palettes are specified.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(surface_hide = true,
                   enhanced3d   = true,
                   palette      = gray,
                   explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3))$

Graphic option: point_size

  Default value: 1

  `point_size` sets the size for plotted points. It must be a non negative number.

  This option affects the following graphic objects:

  - `gr2d`: `points`.
  - `gr3d`: `points`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(points(makelist([random(20),random(50)],k,1,10)),
              point_size = 5,
              points(makelist(k,k,1,20),makelist(random(30),k,1,20)))$

Graphic option: point_type

  Default value: 1

  `point_type` indicates how isolated points are displayed; the value of this option can be any integer index greater or equal than -1, or the name of a point style: `$none` (-1), `dot` (0), `plus` (1), `multiply` (2), `asterisk` (3), `square` (4), `filled_square` (5), `circle` (6), `filled_circle` (7), `up_triangle` (8), `filled_up_triangle` (9), `down_triangle` (10), `filled_down_triangle` (11), `diamant` (12) and `filled_diamant` (13).

  This option affects the following graphic objects:

  - `gr2d`: `points`.
  - `gr3d`: `points`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange = [0,10],
                   yrange = [0,10],
                   point_size = 3,
                   point_type = diamant,
                   points([[1,1],[5,1],[9,1]]),
                   point_type = filled_down_triangle,
                   points([[1,2],[5,2],[9,2]]),
                   point_type = asterisk,
                   points([[1,3],[5,3],[9,3]]),
                   point_type = filled_diamant,
                   points([[1,4],[5,4],[9,4]]),
                   point_type = 5,
                   points([[1,5],[5,5],[9,5]]),
                   point_type = 6,
                   points([[1,6],[5,6],[9,6]]),
                   point_type = filled_circle,
                   points([[1,7],[5,7],[9,7]]),
                   point_type = 8,
                   points([[1,8],[5,8],[9,8]]),
                   point_type = filled_diamant,
                   points([[1,9],[5,9],[9,9]]) )$

Graphic option: points_joined

  Default value: `false`

  If `points_joined` is `true`, points are joined by lines.

  This option affects the following graphic objects:

  - `gr2d`: `points`.
  - `gr3d`: `points`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange        = [0,10],
                   yrange        = [0,4],
                   point_size    = 3,
                   point_type    = up_triangle,
                   color         = blue,
                   points([[1,1],[5,1],[9,1]]),
                   points_joined = true,
                   point_type    = square,
                   line_type     = dots,
                   points([[1,2],[5,2],[9,2]]),
                   point_type    = circle,
                   color         = red,
                   line_width    = 7,
                   points([[1,3],[5,3],[9,3]]) )$

Graphic option: filled_func

  Default value: `false`

  `filled_func` indicates whether a function is filled (`true`) or not (`false`).

  This option affects only the 2d graphic object `explicit`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(fill_color  = red,
                   filled_func = true,
                   explicit(sin(x),x,0,10) )$

  See also `fill_color`.

Graphic option: transparent

  Default value: `false`

  If `transparent` is `true`, interior regions of polygons are filled according to `fill_color`.

  This option affects the following graphic objects:

  - `gr2d`: `polygon`, `rectangle`, and `ellipse`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(polygon([[3,2],[7,2],[5,5]]),
                   transparent = true,
                   color       = blue,
                   polygon([[5,2],[9,2],[7,5]]) )$

Graphic option: border

  Default value: `true`

  If `border` is `true`, borders of polygons are painted according to `line_type` and `line_width`.

  This option affects the following graphic objects:

  - `gr2d`: `polygon`, `rectangle`, and `ellipse`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(color       = brown,
                   line_width  = 8,
                   polygon([[3,2],[7,2],[5,5]]),
                   border      = false,
                   fill_color  = blue,
                   polygon([[5,2],[9,2],[7,5]]) )$

Graphic option: head_both

  Default value: `false`

  If `head_both` is `true`, vectors are plotted with two arrow heads. If `false`, only one arrow is plotted.

  This option is relevant only for `vector` objects.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange      = [0,8],
                   yrange      = [0,8],
                   head_length = 0.7,
                   vector([1,1],[6,0]),
                   head_both   = true,
                   vector([1,7],[6,0]) )$

  See also `head_length`, `head_angle`, and `head_type`.

Graphic option: head_length

  Default value: 2

  `head_length` indicates, in x-axis units, the length of arrow heads.

  This option is relevant only for `vector` objects.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange      = [0,12],
                   yrange      = [0,8],
                   vector([0,1],[5,5]),
                   head_length = 1,
                   vector([2,1],[5,5]),
                   head_length = 0.5,
                   vector([4,1],[5,5]),
                   head_length = 0.25,
                   vector([6,1],[5,5]))$

  See also `head_both`, `head_angle`, and `head_type`.

Graphic option: head_angle

  Default value: 45

  `head_angle` indicates the angle, in degrees, between the arrow heads and the segment.

  This option is relevant only for `vector` objects.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange      = [0,10],
                   yrange      = [0,9],
                   head_length = 0.7,
                   head_angle  = 10,
                   vector([1,1],[0,6]),
                   head_angle  = 20,
                   vector([2,1],[0,6]),
                   head_angle  = 30,
                   vector([3,1],[0,6]),
                   head_angle  = 40,
                   vector([4,1],[0,6]),
                   head_angle  = 60,
                   vector([5,1],[0,6]),
                   head_angle  = 90,
                   vector([6,1],[0,6]),
                   head_angle  = 120,
                   vector([7,1],[0,6]),
                   head_angle  = 160,
                   vector([8,1],[0,6]),
                   head_angle  = 180,
                   vector([9,1],[0,6]) )$

  See also `head_both`, `head_length`, and `head_type`.

Graphic option: head_type

  Default value: `filled`

  `head_type` is used to specify how arrow heads are plotted. Possible values are: `filled` (closed and filled arrow heads), `empty` (closed but not filled arrow heads), and `nofilled` (open arrow heads).

  This option is relevant only for `vector` objects.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange      = [0,12],
                   yrange      = [0,10],
                   head_length = 1,
                   vector([0,1],[5,5]), /* default type */
                   head_type = 'empty,
                   vector([3,1],[5,5]),
                   head_type = 'nofilled,
                   vector([6,1],[5,5]))$

  See also `head_both`, `head_angle`, and `head_length`.

Graphic option: label_alignment

  Default value: `center`

  `label_alignment` is used to specify where to write labels with respect to the given coordinates. Possible values are: `center`, `left`, and `right`.

  This option is relevant only for `label` objects.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange          = [0,10],
                   yrange          = [0,10],
                   points_joined   = true,
                   points([[5,0],[5,10]]),
                   color           = blue,
                   label(["Centered alignment (default)",5,2]),
                   label_alignment = 'left,
                   label(["Left alignment",5,5]),
                   label_alignment = 'right,
                   label(["Right alignment",5,8]))$

  See also `label_orientation`, and `color`.

Graphic option: label_orientation

  Default value: `horizontal`

  `label_orientation` is used to specify orientation of labels. Possible values are: `horizontal`, and `vertical`.

  This option is relevant only for `label` objects.

  Example:

  In this example, a dummy point is added to get an image. Package `draw` needs always data to draw an scene.

      (%i1) load(draw)$
      (%i2) draw2d(xrange     = [0,10],
                   yrange     = [0,10],
                   point_size = 0,
                   points([[5,5]]),
                   color      = navy,
                   label(["Horizontal orientation (default)",5,2]),
                   label_orientation = 'vertical,
                   color             = "#654321",
                   label(["Vertical orientation",1,5]))$

  See also `label_alignment` and `color`.

Graphic option: color

  Default value: `"black"`

  `color` specifies the color for plotting lines, points, borders of polygons and labels.

  Colors can be given as names or in hexadecimal rgb code.

  Available color names are: `"white"`, `"black"`, `"gray0"`, `"grey0"`, `"gray10"`, `"grey10"`, `"gray20"`, `"grey20"`, `"gray30"`, `"grey30"`, `"gray40"`, `"grey40"`, `"gray50"`, `"grey50"`, `"gray60"`, `"grey60"`, `"gray70"`, `"grey70"`, `"gray80"`, `"grey80"`, `"gray90"`, `"grey90"`, `"gray100"`, `"grey100"`, `"gray"`, `"grey"`, `"light-gray"`, `"light-grey"`, `"dark-gray"`, `"dark-grey"`, `"red"`, `"light-red"`, `"dark-red"`, `"yellow"`, `"light-yellow"`, `"dark-yellow"`, `"green"`, `"light-green"`, `"dark-green"`, `"spring-green"`, `"forest-green"`, `"sea-green"`, `"blue"`, `"light-blue"`, `"dark-blue"`, `"midnight-blue"`, `"navy"`, `"medium-blue"`, `"royalblue"`, `"skyblue"`, `"cyan"`, `"light-cyan"`, `"dark-cyan"`, `"magenta"`, `"light-magenta"`, `"dark-magenta"`, `"turquoise"`, `"light-turquoise"`, `"dark-turquoise"`, `"pink"`, `"light-pink"`, `"dark-pink"`, `"coral"`, `"light-coral"`, `"orange-red"`, `"salmon"`, `"light-salmon"`, `"dark-salmon"`, `"aquamarine"`, `"khaki"`, `"dark-khaki"`, `"goldenrod"`, `"light-goldenrod"`, `"dark-goldenrod"`, `"gold"`, `"beige"`, `"brown"`, `"orange"`, `"dark-orange"`, `"violet"`, `"dark-violet"`, `"plum"` and `"purple"`.

  Cromatic componentes in hexadecimal code are introduced in the form `"#rrggbb"`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(explicit(x^2,x,-1,1), /* default is black */
                   color = "red",
                   explicit(0.5 + x^2,x,-1,1),
                   color = blue,
                   explicit(1 + x^2,x,-1,1),
                   color = "light-blue", /* double quotes if - is used */
                   explicit(1.5 + x^2,x,-1,1),
                   color = "#23ab0f",
                   label(["This is a label",0,1.2])  )$

  See also `fill_color`.

Graphic option: fill_color

  Default value: `"red"`

  `fill_color` specifies the color for filling polygons and 2d explicit functions.

  See `color` to learn how colors are specified.

Graphic option: line_width

  Default value: 1

  `line_width` is the width of plotted lines. Its value must be a positive number.

  This option affects the following graphic objects:

  - `gr2d`: `points`, `polygon`, `rectangle`, `ellipse`, `vector`, `explicit`, `implicit`, `parametric` and `polar`.
  - `gr3d`: `points` and `parametric`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(explicit(x^2,x,-1,1), /* default width */
                   line_width = 5.5,
                   explicit(1 + x^2,x,-1,1),
                   line_width = 10,
                   explicit(2 + x^2,x,-1,1))$

  See also `line_type`.

Graphic option: line_type

  Default value: `solid`

  `line_type` indicates how lines are displayed; possible values are `solid` and `dots`.

  This option affects the following graphic objects:

  - `gr2d`: `points`, `polygon`, `rectangle`, `ellipse`, `vector`, `explicit`, `implicit`, `parametric` and `polar`.
  - `gr3d`: `points`, `explicit`, `parametric` and `parametric_surface`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(line_type = dots,
                   explicit(1 + x^2,x,-1,1),
                   line_type = solid, /* default */
                   explicit(2 + x^2,x,-1,1))$

  See also `line_width`.

Graphic option: nticks

  Default value: 30

  `nticks` is the number of sample points used by the plotting routine.

  This option affects the following graphic objects:

  - `gr2d`: `ellipse`, `explicit`, `parametric` and `polar`.
  - `gr3d`: `parametric`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(transparent = true,
                   ellipse(0,0,4,2,0,180),
                   nticks = 5,
                   ellipse(0,0,4,2,180,180) )$

Graphic option: adapt_depth

  Default value: 10

  `adapt_depth` is the maximum number of splittings used by the adaptive plotting routine.

  This option is relevant only for 2d `explicit` functions.

Graphic option: key

  Default value: `""` (empty string)

  `key` is the name of a function in the legend. If `key` is an empty string, no key is assigned to the function.

  This option affects the following graphic objects:

  - `gr2d`: `points`, `polygon`, `rectangle`, `ellipse`, `vector`, `explicit`, `implicit`, `parametric`, and `polar`.
  - `gr3d`: `points`, `explicit`, `parametric`, and `parametric_surface`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(key   = "Sinus",
                   explicit(sin(x),x,0,10),
                   key   = "Cosinus",
                   color = red,
                   explicit(cos(x),x,0,10) )$

Graphic option: xu_grid

  Default value: 30

  `xu_grid` is the number of coordinates of the first variable (`x` in explicit and `u` in parametric 3d surfaces) to build the grid of sample points.

  This option affects the following graphic objects:

  - `gr3d`: `explicit` and `parametric_surface`.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(xu_grid = 10,
                   yv_grid = 50,
                   explicit(x^2+y^2,x,-3,3,y,-3,3) )$

  See also `yv_grid`.

Graphic option: yv_grid

  Default value: 30

  `yv_grid` is the number of coordinates of the second variable (`y` in explicit and `v` in parametric 3d surfaces) to build the grid of sample points.

  This option affects the following graphic objects:

  - `gr3d`: `explicit` and `parametric_surface`.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(xu_grid = 10,
                   yv_grid = 50,
                   explicit(x^2+y^2,x,-3,3,y,-3,3) )$

  See also `xu_grid`.

Graphic option: surface_hide

  Default value: `false`

  If `surface_hide` is `true`, hidden parts are not plotted in 3d surfaces.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw(columns=2,
                 gr3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3)),
                 gr3d(surface_hide = true,
                      explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3)) )$

Graphic option: contour

  Default value: `none`

  Option `contour` enables the user to select where to plot contour lines. Possible values are:

  - `none`: no contour lines are plotted.
  - `base`: contour lines are projected on the xy plane.
  - `surface`: contour lines are plotted on the surface.
  - `both`: two contour lines are plotted: on the xy plane and on the surface.
  - `map`: contour lines are projected on the xy plane, and the view point is set just in the vertical.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
                   contour_levels = 15,
                   contour        = both,
                   surface_hide   = true) $

Graphic option: contour_levels

  Default value: 5

  `contour_levels` is the number of levels in contour plots.

  Since this is a global graphics option, its position in the scene description does not matter.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
                   contour_levels = 15,
                   contour        = both,
                   surface_hide   = true) $

Graphic option: columns

  Default value: 1

  `columns` is the number of columns in multiple plots.

  Since this is a global graphics option, its position in the scene description does not matter. It can be also used as an argument of function `draw`.

  Example:

      (%i1) load(draw)$
      (%i2) scene1: gr2d(title="Ellipse",
                         nticks=30,
                         parametric(2*cos(t),5*sin(t),t,0,2*%pi))$
      (%i3) scene2: gr2d(title="Triangle",
                         polygon([4,5,7],[6,4,2]))$
      (%i4) draw(scene1, scene2, columns = 2)$

Graphic option: ip_grid

  Default value: `[50, 50]`

  `ip_grid` sets the grid for the first sampling in implicit plots.

  This option is relevant only for `implicit` objects.

Graphic option: ip_grid_in

  Default value: `[5, 5]`

  `ip_grid_in` sets the grid for the second sampling in implicit plots.

  This option is relevant only for `implicit` objects.

Scene constructor: gr2d (graphic option, ..., graphic object, ...)

  Function `gr2d` builds an object describing a 2D scene. Arguments are graphic options and graphic objects. This scene is interpreted sequentially: graphic options affect those graphic objects placed on its right. Some graphic options affect the global appearence of the scene.

  This is the list of graphic objects available for scenes in two dimensions: `points`, `polygon`, `rectangle`, `ellipse`, `label`, `vector`, `explicit`, `implicit`, `polar`, `parametric`, `image` and `geomap`.

  See also the following global graphic options: `xrange`, `yrange`, `logx`, `logy`, `terminal`, `grid`, `title`, `xlabel`, `ylabel`, `xtics`, `ytics`, `xy_file`, `file_name`, `pic_width`, `pic_height`, `eps_width`, `eps_height`, `user_preamble`, `axis_bottom`, `axis_left`, `axis_top` and `axis_right`.

  To make use of this function, write first `load(draw)`.

Scene constructor: gr3d (graphic option, ..., graphic object, ...)

  Function `gr3d` builds an object describing a 3d scene. Arguments are graphic options and graphic objects. This scene is interpreted sequentially: graphic options affect those graphic objects placed on its right. Some graphic options affect the global appearence of the scene.

  This is the list of graphic objects available for scenes in three dimensions: `points`, `label`, `vector`, `explicit`, `parametric` and `parametric_surface`.

  See also the following graphic options: `xrange`, `yrange`, `zrange`, `logx`, `logy`, `logz`, `terminal`, `grid`, `title`, `xlabel`, `ylabel`, `zlabel`, `xtics`, `ytics`, `ztics`, `xy_file`, `user_preamble`, `axis_bottom`, `axis_left`, `axis_top`, `file_name`, `pic_width`, `pic_height`, `eps_width`, `eps_height`, `axis_right`, `rot_vertical`, `rot_horizontal`, `axis_3d`, `xu_grid`, `yv_grid`, `surface_hide`, `contour`, `contour_levels`, `palette`, `colorbox` and `enhanced3d`.

  To make use of this function, write first `load(draw)`.

Graphic object: points ([[x1,y1], [x2,y2],...])
Graphic object: points ([x1,x2,...], [y1,y2,...])
Graphic object: points ([y1,y2,...])
Graphic object: points ([[x1,y1,z1], [x2,y2,z2],...])
Graphic object: points ([x1,x2,...], [y1,y2,...], [z1,z2,...])

  Draws points in 2D and 3D.

  This object is affected by the following graphic options: `point_size`, `point_type`, `points_joined`, `line_width`, `key`, `line_type` and `color`.

  2D

  `points ([[x1,y1], [x2,y2],...])` or `points ([x1,x2,...], [y1,y2,...])` plots points `[x1,y1]`, `[x2,y2]`, etc. If abscissas are not given, they are set to consecutive positive integers, so that `points ([y1,y2,...])` draws points `[1,y1]`, `[2,y2]`, etc.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(
              key = "Small points",
              points(makelist([random(20),random(50)],k,1,10)),
              point_type    = circle,
              point_size    = 3,
              points_joined = true,
              key           = "Great points",
              points(makelist(k,k,1,20),makelist(random(30),k,1,20)),
              point_type    = filled_down_triangle,
              key           = "Automatic abscissas",
              color         = red,
              points([2,12,8]))$

  3D

  `points ([[x1,y1,z1], [x2,y2,z2],...])` or `points ([x1,x2,...], [y1,y2,...], [z1,z2,...])` plots points `[x1,y1,z1]`, `[x2,y2,z2]`, etc.

  Examples:

  One tridimensional sample,

      (%i1) load(draw)$
      (%i2) load (numericalio)$
      (%i3) s2 : read_matrix (file_search ("wind.data"))$
      (%i4) draw3d(title = "Daily average wind speeds",
                   point_size = 2,
                   points(args(submatrix (s2, 4, 5))) )$

  Two tridimensional samples,

      (%i1) load(draw)$
      (%i2) load (numericalio)$
      (%i3) s2 : read_matrix (file_search ("wind.data"))$
      (%i4) draw3d(
               title = "Daily average wind speeds. Two data sets",
               point_size = 2,
               key        = "Sample from stations 1, 2 and 3",
               points(args(submatrix (s2, 4, 5))),
               point_type = 4,
               key        = "Sample from stations 1, 4 and 5",
               points(args(submatrix (s2, 2, 3))) )$

Graphic object: polygon ([[x1,y1], [x2,y2],...])
Graphic object: polygon ([x1,x2,...], [y1,y2,...])

  Draws polygons in 2D.

  2D

  `polygon ([[x1,y1], [x2,y2],...])` or `polygon ([x1,x2,...], [y1,y2,...])`: plots on the plane a polygon with vertices `[x1,y1]`, `[x2,y2]`, etc..

  This object is affected by the following graphic options: `transparent`, `fill_color`, `border`, `line_width`, `key`, `line_type` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(color      = "#e245f0",
                   line_width = 8,
                   polygon([[3,2],[7,2],[5,5]]),
                   border      = false,
                   fill_color  = yellow,
                   polygon([[5,2],[9,2],[7,5]]) )$

Graphic object: rectangle ([x1,y1], [x2,y2])

  Draws rectangles in 2D.

  2D

  `rectangle ([x1,y1], [x2,y2])` draws a rectangle with opposite vertices `[x1,y1]` and `[x2,y2]`.

  This object is affected by the following graphic options: `transparent`, `fill_color`, `border`, `line_width`, `key`, `line_type` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(fill_color  = red,
                   line_width  = 6,
                   line_type   = dots,
                   transparent = false,
                   fill_color  = blue,
                   rectangle([-2,-2],[8,-1]), /* opposite vertices */
                   transparent = true,
                   line_type   = solid,
                   line_width  = 1,
                   rectangle([9,4],[2,-1.5]),
                   xrange      = [-3,10],
                   yrange      = [-3,4.5] )$

Graphic object: ellipse (xc, yc, a, b, ang1, ang2)

  Draws ellipses and circles in 2D.

  2D

  `ellipse (xc, yc, a, b, ang1, ang2)` plots an ellipse centered at `[xc, yc]` with horizontal and vertical semi axis a and b, respectively, from angle ang1 to angle ang2.

  This object is affected by the following graphic options: `nticks`, `transparent`, `fill_color`, `border`, `line_width`, `line_type`, `key` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(transparent = false,
                   fill_color  = red,
                   color       = gray30,
                   transparent = false,
                   line_width  = 5,
                   ellipse(0,6,3,2,270,-270),
                   /* center (x,y), a, b, start & end in degrees */
                   transparent = true,
                   color       = blue,
                   line_width  = 3,
                   ellipse(2.5,6,2,3,30,-90),
                   xrange      = [-3,6],
                   yrange      = [2,9] )$

Graphic object: label ([string,x,y],...)
Graphic object: label ([string,x,y,z],...)

  Writes labels in 2D and 3D.

  This object is affected by the following graphic options: `label_alignment`, `label_orientation` and `color`.

  2D

  `label([string,x,y])` writes the string at point `[x,y]`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(yrange = [0.1,1.4],
                   color = "red",
                   label(["Label in red",0,0.3]),
                   color = "#0000ff",
                   label(["Label in blue",0,0.6]),
                   color = "light-blue",
                   label(["Label in light-blue",0,0.9],
                         ["Another ligght-blue",0,1.2])  )$

  3D

  `label([string,x,y,z])` writes the string at point `[x,y,z]`.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3),
                   color = red,
                   label(["UP 1",-2,0,3], ["UP 2",1.5,0,4]),
                   color = blue,
                   label(["DOWN 1",2,0,-3]) )$

Graphic object: vector ([x,y], [dx,dy])
Graphic object: vector ([x,y,z], [dx,dy,dz])

  Draws vectors in 2D and 3D.

  This object is affected by the following graphic options: `head_both`, `head_length`, `head_angle`, `head_type`, `line_width`, `line_type`, `key` and `color`.

  2D

  `vector([x,y], [dx,dy])` plots vector `[dx,dy]` with origin in `[x,y]`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(xrange      = [0,12],
                   yrange      = [0,10],
                   head_length = 1,
                   vector([0,1],[5,5]), /* default type */
                   head_type = 'empty,
                   vector([3,1],[5,5]),
                   head_both = true,
                   head_type = 'nofilled,
                   line_type = dots,
                   vector([6,1],[5,5]))$

  3D

  `vector([x,y,z], [dx,dy,dz])` plots vector `[dx,dy,dz]` with origin in `[x,y,z]`.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(color = cyan,
                   vector([0,0,0],[1,1,1]/sqrt(3)),
                   vector([0,0,0],[1,-1,0]/sqrt(2)),
                   vector([0,0,0],[1,1,-2]/sqrt(6)) )$

Graphic object: explicit (fcn,var,minval,maxval)
Graphic object: explicit (fcn,var1,minval1,maxval1,var2,minval2,maxval2)

  Draws explicit functions in 2D and 3D.

  2D

  `explicit(fcn,var,minval,maxval)` plots explicit function fcn, with variable var taking values from minval to maxval.

  This object is affected by the following graphic options: `nticks`, `adapt_depth`, `line_width`, `line_type`, `key`, `filled_func`, `fill_color` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(line_width = 3,
                   color      = blue,
                   explicit(x^2,x,-3,3) )$
      (%i3) draw2d(fill_color  = brown,
                   filled_func = true,
                   explicit(x^2,x,-3,3) )$

  3D

  `explicit(fcn,var1,minval1,maxval1,var2,minval2,maxval2)` plots explicit function fcn, with variable var1 taking values from minval1 to maxval1 and variable var2 taking values from minval2 to maxval2.

  This object is affected by the following graphic options: `xu_grid`, `yv_grid`, `line_type`, `key` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(key   = "Gauss",
                   color = "#a02c00",
                   explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3),
                   yv_grid     = 10,
                   color = blue,
                   key   = "Plane",
                   explicit(x+y,x,-5,5,y,-5,5),
                   surface_hide = true)$

Graphic object: implicit (fcn,xvar,xminval,xmaxval,yvar,yminval,ymaxval)

  Draws implicit functions in 2D.

  2D

  `implicit(fcn,xvar,xminval,xmaxval,yvar,yminval,ymaxval)` plots the implicit function defined by fcn, with variable xvar taking values from xminval to xmaxval, and variable yvar taking values from yminval to ymaxval.

  This object is affected by the following graphic options: `ip_grid`, `ip_grid_in`, `line_width`, `line_type`, `key` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(terminal  = eps,
                   grid      = true,
                   line_type = solid,
                   key       = "y^2=x^3-2*x+1",
                   implicit(y^2=x^3-2*x+1, x, -4,4, y, -4,4),
                   line_type = dots,
                   key       = "x^3+y^3 = 3*x*y^2-x-1",
                   implicit(x^3+y^3 = 3*x*y^2-x-1, x,-4,4, y,-4,4),
                   title     = "Two implicit functions" )$

Graphic object: polar (radius,ang,minang,maxang)

  Draws 2D functions defined in polar coordinates.

  2D

  `polar (radius,ang,minang,maxang)` plots function `radius(ang)` defined in polar coordinates, with variable ang taking values from minang to maxang.

  This object is affected by the following graphic options: `nticks`, `line_width`, `line_type`, `key` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(user_preamble = "set grid polar",
                   nticks        = 200,
                   xrange        = [-5,5],
                   yrange        = [-5,5],
                   color         = blue,
                   line_width    = 3,
                   title         = "Hyperbolic Spiral",
                   polar(10/theta,theta,1,10*%pi) )$

Graphic object: parametric (xfun,yfun,par,parmin,parmax)
Graphic object: parametric (xfun,yfun,zfun,par,parmin,parmax)

  Draws parametric functions in 2D and 3D.

  This object is affected by the following graphic options: `nticks`, `line_width`, `line_type`, `key` and `color`.

  2D

  `parametric (xfun,yfun,par,parmin,parmax)` plots parametric function `[xfun,yfun]`, with parameter par taking values from parmin to parmax.

  Example:

      (%i1) load(draw)$
      (%i2) draw2d(explicit(exp(x),x,-1,3),
                   color = red,
                   key   = "This is the parametric one!!",
                   parametric(2*cos(rrr),rrr^2,rrr,0,2*%pi))$

  3D

  `parametric (xfun,yfun,zfun,par,parmin,parmax)` plots parametric curve `[xfun,yfun,zfun]`, with parameter par taking values from parmin to parmax.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3),
                   color = royalblue,
                   parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2),
                   color      = turquoise,
                   line_width = 2,
                   parametric(t^2,sin(t),2+t,t,0,2),
                   surface_hide = true,
                   title = "Surface & curves" )$

Graphic object: image (im,x0,y0,width,height)

  Renders images in 2D.

  2D

  `image (im,x0,y0,width,height)` plots image im in the rectangular region from vertex `(x0,y0)` to `(x0+width,y0+height)` on the real plane. Argument im must be a matrix of real numbers, a matrix of vectors of length three or a picture object.

  If im is a matrix of real numbers or a `levels picture` object, pixel values are interpreted according to graphic option `palette`, which is a vector of length three with components ranging from -36 to +36; each value is an index for a formula mapping the levels onto red, green and blue colors, respectively:

       0: 0               1: 0.5           2: 1
       3: x               4: x^2           5: x^3
       6: x^4             7: sqrt(x)       8: sqrt(sqrt(x))
       9: sin(90x)       10: cos(90x)     11: |x-0.5|
      12: (2x-1)^2       13: sin(180x)    14: |cos(180x)|
      15: sin(360x)      16: cos(360x)    17: |sin(360x)|
      18: |cos(360x)|    19: |sin(720x)|  20: |cos(720x)|
      21: 3x             22: 3x-1         23: 3x-2
      24: |3x-1|         25: |3x-2|       26: (3x-1)/2
      27: (3x-2)/2       28: |(3x-1)/2|   29: |(3x-2)/2|
      30: x/0.32-0.78125                  31: 2*x-0.84
      32: 4x;1;-2x+1.84;x/0.08-11.5
      33: |2*x - 0.5|    34: 2*x          35: 2*x - 0.5
      36: 2*x - 1

  negative numbers mean negative colour component.

  `palette = gray` and `palette = color` are short cuts for `palette = [3,3,3]` and `palette = [7,5,15]`, respectively.

  If im is a matrix of vectors of length three or an `rgb picture` object, they are interpreted as red, green and blue color components.

  Examples:

  If im is a matrix of real numbers, pixel values are interpreted according to graphic option `palette`.

      (%i1) load(draw)$
      (%i2) im: apply(
                 'matrix,
                  makelist(makelist(random(200),i,1,30),i,1,30))$
      (%i3) /* palette = color, default */
            draw2d(image(im,0,0,30,30))$
      (%i4) draw2d(palette = gray, image(im,0,0,30,30))$
      (%i5) draw2d(palette = [15,20,-4],
                   colorbox=false,
                   image(im,0,0,30,30))$

  See also `colorbox`.

  If im is a matrix of vectors of length three, they are interpreted as red, green and blue color components.

      (%i1) load(draw)$
      (%i2) im: apply(
                  'matrix,
                   makelist(
                     makelist([random(300),
                               random(300),
                               random(300)],i,1,30),i,1,30))$
      (%i3) draw2d(image(im,0,0,30,30))$

  Package `draw` automatically loads package `picture`. In this example, a level picture object is built by hand and then rendered.

      (%i1) load(draw)$
      (%i2) im: make_level_picture([45,87,2,134,204,16],3,2);
      (%o2)       picture(level, 3, 2, {Array:  #(45 87 2 134 204 16)})
      (%i3) /* default color palette */
            draw2d(image(im,0,0,30,30))$
      (%i4) /* gray palette */
            draw2d(palette = gray,
                   image(im,0,0,30,30))$

  An xpm file is read and then rendered.

      (%i1) load(draw)$
      (%i2) im: read_xpm("myfile.xpm")$
      (%i3) draw2d(image(im,0,0,10,7))$

  See also `make_level_picture`, `make_rgb_picture` and `read_xpm`.

  URL http://www.telefonica.net/web2/biomates/maxima/gpdraw/image contains more elaborated examples.

Global variable: boundaries_array

  Default value: `false`

  `boundaries_array` is where the graphic object `geomap` looks for boundaries coordinates.

  Each component of `boundaries_array` is an array of floating point quantities, the coordinates of a polygonal segment or map boundary.

  See also `geomap`.

Graphic object: geomap (n1,n2,...)

  Draws cartographic maps in 2D.

  2D

  This function works together with global variable `boundaries_array`.

  Arguments are numbers or lists containing numbers or lists of numbers. All these numbers must be integers greater or equal than zero, representing the components of global array `boundaries_array`.

  Each component of `boundaries_array` is an array of floating point quantities, the coordinates of a polygonal segment or map boundary.

  `geomap (n1,n2,...)` flattens its arguments and draws the associated boundaries in `boundaries_array`.

  This object is affected by the following graphic options: `line_width`, `line_type` and `color`.

  Examples:

  A simple map defined by hand:

      (%i1) load(draw)$
      (%i2) /* Vertices of boundary #0: {(1,1),(2,5),(4,3)} */
         ( bnd0: make_array(flonum,6),
           bnd0[0]:1.0, bnd0[1]:1.0, bnd0[2]:2.0,
           bnd0[3]:5.0, bnd0[4]:4.0, bnd0[5]:3.0 )$
      (%i3) /* Vertices of boundary #1: {(4,3),(5,4),(6,4),(5,1)} */
         ( bnd1: make_array(flonum,8),
           bnd1[0]:4.0, bnd1[1]:3.0, bnd1[2]:5.0, bnd1[3]:4.0,
           bnd1[4]:6.0, bnd1[5]:4.0, bnd1[6]:5.0, bnd1[7]:1.0)$
      (%i4) /* Vertices of boundary #2: {(5,1), (3,0), (1,1)} */
         ( bnd2: make_array(flonum,6),
           bnd2[0]:5.0, bnd2[1]:1.0, bnd2[2]:3.0,
           bnd2[3]:0.0, bnd2[4]:1.0, bnd2[5]:1.0 )$
      (%i5) /* Vertices of boundary #3: {(1,1), (4,3)} */
         ( bnd3: make_array(flonum,4),
           bnd3[0]:1.0, bnd3[1]:1.0, bnd3[2]:4.0, bnd3[3]:3.0)$
      (%i6) /* Vertices of boundary #4: {(4,3), (5,1)} */
         ( bnd4: make_array(flonum,4),
           bnd4[0]:4.0, bnd4[1]:3.0, bnd4[2]:5.0, bnd4[3]:1.0)$
      (%i7) /* Pack all together in boundaries_array */
         ( boundaries_array: make_array(any,5),
           boundaries_array[0]: bnd0, boundaries_array[1]: bnd1,
           boundaries_array[2]: bnd2, boundaries_array[3]: bnd3,
           boundaries_array[4]: bnd4 )$
      (%i8) draw2d(geomap([0,1,2,3,4]))$

  Auxiliary package `worldmap` sets global variable `boundaries_array` to real world boundaries in (longitude, latitude) coordinates. These data are in the public domain and come from http://www-cger.nies.go.jp/grid-e/gridtxt/grid19.html. Package `worldmap` defines also boundaries for countries and continents as lists with the necessary components of `boundaries_array` (see file `share/draw/worldmap.mac` for more information). Package `draw` does not automatically load `worldmap`.

      (%i1) load(draw)$
      (%i2) load(worldmap)$
      (%i3) c1: gr2d(geomap(Canada,United_States,
                            Mexico,Cuba))$
      (%i4) c2: gr2d(geomap(Africa))$
      (%i5) c3: gr2d(geomap(Oceania,China,Japan))$
      (%i6) c4: gr2d(geomap(France,Portugal,Spain,
                            Morocco,Western_Sahara))$
      (%i7) draw(columns  = 2,
                 c1,c2,c3,c4)$

  Package `worldmap` is also useful for plotting countries as polygons. In this case, graphic object `geomap` is no longer necessary and the `polygon` object is used instead. Since lists are now used and not arrays, maps rendering will be slower. See also `make_poly_country` and `make_poly_continent` to understand the following code.

      (%i1) load(draw)$
      (%i2) load(worldmap)$
      (%i3) mymap: append(
         [color      = white],  /* borders are white */
         [fill_color = red],             make_poly_country(Bolivia),
         [fill_color = cyan],            make_poly_country(Paraguay),
         [fill_color = green],           make_poly_country(Colombia),
         [fill_color = blue],            make_poly_country(Chile),
         [fill_color = "#23ab0f"],       make_poly_country(Brazil),
         [fill_color = goldenrod],       make_poly_country(Argentina),
         [fill_color = "midnight-blue"], make_poly_country(Uruguay))$
      (%i4) apply(draw2d, mymap)$

  See also http://www.telefonica.net/web2/biomates/maxima/gpdraw/geomap for more elaborated examples.

Graphic object: parametric_surface (xfun,yfun,zfun,par1,par1min,par1max,par2,par2min,par2max)

  Draws parametric surfaces in 3D.

  3D

  `parametric_surface (xfun,yfun,zfun,par1,par1min,par1max,par2,par2min,par2max)` plots parametric surface `[xfun,yfun,zfun]`, with parameter par1 taking values from par1min to par1max and parameter par2 taking values from par2min to par2max.

  This object is affected by the following graphic options: `xu_grid`, `yv_grid`, `line_type`, `key` and `color`.

  Example:

      (%i1) load(draw)$
      (%i2) draw3d(title          = "Sea shell",
                   xu_grid        = 100,
                   yv_grid        = 25,
                   rot_vertical   = 100,
                   rot_horizontal = 20,
                   surface_hide   = true,
                   parametric_surface(0.5*u*cos(u)*(cos(v)+1),
                                 0.5*u*sin(u)*(cos(v)+1),
                                 u*sin(v) - ((u+3)/8*%pi)^2 - 20,
                                 u, 0, 13*%pi, v, -%pi, %pi) )$

Function: draw (gr2d, ..., gr3d, ..., options, ...)

  Plots a series of scenes; its arguments are `gr2d` and/or `gr3d` objects, together with some options. By default, the scenes are put together in one column.

  Function `draw` accepts two possible options: `terminal` and `columns`.

  Functions `draw2d` and `draw3d` are short cuts to be used when only one scene is required, in two or three dimensions, respectively.

  To make use of this function, write first `load(draw)`.

  Example:

      (%i1) load(draw)$
      (%i2) scene1: gr2d(title="Ellipse",
                         nticks=30,
                         parametric(2*cos(t),5*sin(t),t,0,2*%pi))$
      (%i3) scene2: gr2d(title="Triangle",
                         polygon([4,5,7],[6,4,2]))$
      (%i4) draw(scene1, scene2, columns = 2)$

Function: draw2d (option, graphic_object, ...)

  This function is a short cut for `draw2d(gr2d(options, ..., graphic_object, ...))`.

  It can be used to plot a unique scene in 2d.

  To make use of this function, write first `load(draw)`.

Function: draw3d (option, graphic_object, ...)

  This function is a short cut for `draw3d(gr3d(options, ..., graphic_object, ...))`.

  It can be used to plot a unique scene in 3d.

  To make use of this function, write first `load(draw)`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 48.3 Functions and Variables for pictures

Function: make_level_picture (data)
Function: make_level_picture (data,width,height)

  Returns a levels `picture` object. `make_level_picture (data)` builds the `picture` object from matrix data. `make_level_picture (data,width,height)` builds the object from a list of numbers; in this case, both the width and the height must be given.

  The returned `picture` object contains the following four parts:

  1. symbol `level`
  2. image width
  3. image height
  4. an integer array with pixel data ranging from 0 to 255. Argument data must contain only numbers ranged from 0 to 255; negative numbers are substituted by 0, and those which are greater than 255 are set to 255.

  Example:

  Level picture from matrix.

      (%i1) load(draw)$
      (%i2) make_level_picture(matrix([3,2,5],[7,-9,3000]));
      (%o2)         picture(level, 3, 2, {Array:  #(3 2 5 7 0 255)})

  Level picture from numeric list.

      (%i1) load(draw)$
      (%i2) make_level_picture([-2,0,54,%pi],2,2);
      (%o2)            picture(level, 2, 2, {Array:  #(0 0 54 3)})

Function: picturep (x)

  Returns `true` if the argument is a well formed image, and `false` otherwise.

Function: picture_equalp (x,y)

  Returns `true` in case of equal pictures, and `false` otherwise.

Function: make_rgb_picture (redlevel,greenlevel,bluelevel)

  Returns an rgb-coloured `picture` object. All three arguments must be levels picture; with red, green and blue levels.

  The returned `picture` object contains the following four parts:

  1. symbol `rgb`
  2. image width
  3. image height
  4. an integer array of length `3*width*height` with pixel data ranging from 0 to 255. Each pixel is represented by three consecutive numbers (red, green, blue).

  Example:

      (%i1) load(draw)$
      (%i2) red: make_level_picture(matrix([3,2],[7,260]));
      (%o2)           picture(level, 2, 2, {Array:  #(3 2 7 255)})
      (%i3) green: make_level_picture(matrix([54,23],[73,-9]));
      (%o3)           picture(level, 2, 2, {Array:  #(54 23 73 0)})
      (%i4) blue: make_level_picture(matrix([123,82],[45,32.5698]));
      (%o4)          picture(level, 2, 2, {Array:  #(123 82 45 33)})
      (%i5) make_rgb_picture(red,green,blue);
      (%o5) picture(rgb, 2, 2,
                    {Array:  #(3 54 123 2 23 82 7 73 45 255 0 33)})

Function: take_channel (im,color)

  If argument color is red, green or blue, function `take_channel` returns the corresponding color channel of picture im. Example:

      (%i1) load(draw)$
      (%i2) red: make_level_picture(matrix([3,2],[7,260]));
      (%o2)           picture(level, 2, 2, {Array:  #(3 2 7 255)})
      (%i3) green: make_level_picture(matrix([54,23],[73,-9]));
      (%o3)           picture(level, 2, 2, {Array:  #(54 23 73 0)})
      (%i4) blue: make_level_picture(matrix([123,82],[45,32.5698]));
      (%o4)          picture(level, 2, 2, {Array:  #(123 82 45 33)})
      (%i5) make_rgb_picture(red,green,blue);
      (%o5) picture(rgb, 2, 2,
                    {Array:  #(3 54 123 2 23 82 7 73 45 255 0 33)})
      (%i6) take_channel(%,'green);  /* simple quote!!! */
      (%o6)           picture(level, 2, 2, {Array:  #(54 23 73 0)})

Function: negative_picture (pic)

  Returns the negative of a (`level` or `rgb`) picture.

Function: rgb2level (pic)

  Transforms an `rgb` picture into a `level` one by averaging the red, green and blue channels.

Function: get_pixel (pic,x,y)

  Returns pixel from picture. Coordinates x and y range from 0 to `width-1` and `height-1`, respectively.

Function: read_xpm (xpm_file)

  Reads a file in xpm and returns a picture object.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 48.4 Functions and Variables for worldmap

Function: region_boundaries (x1,y1,x2,y2)

  Detects polygonal segments of global variable `boundaries_array` contained in the rectangle with vertices (x1,y1) -upper left- and (x2,y2) -bottom right-.

  Example:

  Returns segment numbers for plotting southern Italy.

      (%i1) load(draw)$
      (%i2) load(worldmap)$
      (%i3) region_boundaries(10.4,41.5,20.7,35.4);
      (%o3)                [1846, 1863, 1864, 1881, 1888, 1894]
      (%i4) draw2d(geomap(%))$

Function: numbered_boundaries (nlist)

  Draws a list of polygonal segments (boundaries), labeled by its numbers (`boundaries_array` coordinates). This is of great help when building new geographical entities.

  Example:

  Map of Europe labeling borders with their component number in `boundaries_array`.

      (%i1) load(draw)$
      (%i2) load(worldmap)$
      (%i3) european_borders:
                 region_boundaries(-31.81,74.92,49.84,32.06)$
      (%i4) numbered_boundaries(european_borders)$

Function: make_polygon (nlist)

  Returns a `polygon` object from boundary indices. Argument nlist is a list of components of `boundaries_array`.

  Example:

  Bhutan is defined by boundary numbers 171, 173 and 1143, so that `make_polygon([171,173,1143])` appends arrays of coordinates `boundaries_array[171]`, `boundaries_array[173]` and `boundaries_array[1143]` and returns a `polygon` object suited to be plotted by `draw`. To avoid an error message, arrays must be compatible in the sense that any two consecutive arrays have two coordinates in the extremes in common. In this example, the two first components of `boundaries_array[171]` are equal to the last two coordinates of `boundaries_array[173]`, and the two first of `boundaries_array[173]` are equal to the two first of `boundaries_array[1143]`; in conclussion, boundary numbers 171, 173 and 1143 (in this order) are compatible and the colored polygon can be drawn.

      (%i1) load(draw)$
      (%i2) load(worldmap)$
      (%i3) Bhutan;
      (%o3)                        [[171, 173, 1143]]
      (%i4) boundaries_array[171];
      (%o4) {Array:
             #(88.750549 27.14727 88.806351 27.25305 88.901367 27.282221
               88.917877 27.321039)}
      (%i5) boundaries_array[173];
      (%o5) {Array:
             #(91.659554 27.76511 91.6008 27.66666 91.598022 27.62499
               91.631348 27.536381 91.765533 27.45694 91.775253 27.4161
               92.007751 27.471939 92.11441 27.28583 92.015259 27.168051
               92.015533 27.08083 92.083313 27.02277 92.112183 26.920271
               92.069977 26.86194 91.997192 26.85194 91.915253 26.893881
               91.916924 26.85416 91.8358 26.863331 91.712479 26.799999
               91.542191 26.80444 91.492188 26.87472 91.418854 26.873329
               91.371353 26.800831 91.307457 26.778049 90.682457 26.77417
               90.392197 26.903601 90.344131 26.894159 90.143044 26.75333
               89.98996 26.73583 89.841919 26.70138 89.618301 26.72694
               89.636093 26.771111 89.360786 26.859989 89.22081 26.81472
               89.110237 26.829161 88.921631 26.98777 88.873016 26.95499
               88.867737 27.080549 88.843307 27.108601 88.750549
               27.14727)}
      (%i6) boundaries_array[1143];
      (%o6) {Array:
             #(91.659554 27.76511 91.666924 27.88888 91.65831 27.94805
               91.338028 28.05249 91.314972 28.096661 91.108856 27.971109
               91.015808 27.97777 90.896927 28.05055 90.382462 28.07972
               90.396088 28.23555 90.366074 28.257771 89.996353 28.32333
               89.83165 28.24888 89.58609 28.139999 89.35997 27.87166
               89.225517 27.795 89.125793 27.56749 88.971077 27.47361
               88.917877 27.321039)}
      (%i7) Bhutan_polygon: make_polygon([171,173,1143])$
      (%i8) draw2d(Bhutan_polygon)$

Function: make_poly_country (country_name)

  Makes the necessary polygons to draw a colored country. If islands exist, one country can be defined with more than just one polygon.

  Example:

      (%i1) load(draw)$
      (%i2) load(worldmap)$
      (%i3) make_poly_country(India)$
      (%i4) apply(draw2d, %)$

Function: make_poly_continent (continent_name)
Function: make_poly_continent (country_list)

  Makes the necessary polygons to draw a colored continent or a list of countries.

  Example:

      (%i1) load(draw)$
      (%i2) load(worldmap)$
      (%i3) /* A continent */
            make_poly_continent(Africa)$
      (%i4) apply(draw2d, %)$
      (%i5) /* A list of countries */
            make_poly_continent([Germany,Denmark,Poland])$
      (%i6) apply(draw2d, %)$

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Robert Dodier on August, 25 2007 using texi2html 1.76.