Back to main page
Back to draw contents

Discrete points and segments

This section shows how to draw discrete points with the draw package. The graphic object to be used is points. Segments requiere to set graphic option points_joined to true.


Discrete samples. Points can be entered in two ways: [[x1,y1],[x2,y2],...] or [[x1,x2,...],[y1,y2,...]].

draw2d(key           = "puntitos",
           points(makelist([random(20),random(50)],k,1,10)),
       point_type    = 6,
       point_size    = 3,
       points_joined = true,
       color         = blue,
       key           = "puntazos",
           points(makelist(k,k,1,20),makelist(random(30),k,1,20)),
       terminal      = png)$

Peano's curve.

load(fractals)$
draw2d(point_size    = 0,
       points_joined = true,
       color         = red,
       title         = "Peano",
          points(sierpinskimap(5)),
       terminal = png) $

No comments.

bs:[[64,-104], [64,-99], [61,-95], [57,-95], [55,-94], [55,-90], [72,-89], [80,-88], [77,-86], [80,-88], 
    [82,-91], [80,-88], [72,-89], [55,-90], [47,-89], [39,-87], [33,-84], [32,-81], [35,-75], [36,-69], 
    [42,-69], [45,-68], [42,-69], [36,-69], [35,-67], [35,-62], [35,-60], [39,-60], [45,-61], [51,-61], 
    [53,-65], [56,-68], [61,-70], [67,-71], [73,-70], [78,-67], [80,-64], [81,-61], [78,-58], [75,-60], 
    [75,-62], [78,-62], [81,-61], [81,-56], [79,-50], [75,-47], [70,-44], [62,-44], [58,-45], [53,-50], 
    [52,-52], [49,-53], [48,-52], [48,-50], [49,-48], [51,-49], [52,-52], [51,-54], [51,-57], [51,-61], 
    [45,-61], [39,-60], [35,-60], [32,-57], [32,-52], [32,-49], [35,-45], [39,-42], [43,-41], [48,-42], 
    [51,-43], [55,-47], [51,-43], [48,-42], [43,-41], [44,-38], [47,-35], [54,-16], [56,-5], [60,-11], 
    [64,-6], [67,-12], [72,-7], [74,-14], [80,-9], [80,-16], [86,-11], [87,-17], [92,-12], [93,-21], 
    [99,-16], [100,-22], [106,-19], [107,-27], [115,-25], [110,-32], [94,-72], [91,-72], [88,-73], [87,-74], 
    [88,-76], [91,-76], [91,-79], [89,-81], [91,-79], [91,-76], [94,-77], [94,-79], [94,-77], [91,-76], 
    [88,-76], [87,-74], [88,-73], [91,-72], [94,-72], [97,-75], [98,-80], [97,-82], [94,-84], [91,-85], 
    [87,-83], [84,-80], [87,-83], [91,-85], [91,-95], [92,-102], [85,-105], [69,-106], [64,-104]]$

draw2d(
  point_type    = dot,
  points_joined = true,
  points(bs) )$

File wind.data, which is part of the Maxima distribution, contains daily average wind speeds at 5 meteorological stations in the Republic of Ireland (This is part of a data set taken at 12 meteorological stations. The original file is freely downloadable from the StatLib Data Repository and its analysis is discused in Haslett, J., Raftery, A. E. (1989) Space-time Modelling with Long-memory Dependence: Assessing Ireland's Wind Power Resource, with Discussion. Applied Statistics 38, 1-50).

In this example, data corresponding to stations number 1, 2 and 3 are represented coordinates in the 3d space.

s2 : read_matrix (file_search ("wind.data"))$
draw3d(title      = "Daily average wind speeds",
       point_size = 2,
       color      = red,
         points(submatrix (s2, 4, 5)) )$

Following with the previous example, now data corresponding to stations 1, 4 and 5, are also plotted.

draw3d(title      = "Daily average wind speeds. Two data sets",
       point_size = 2,
       color      = red,
       key        = "Sample from stations 1, 2 and 3",
         points(submatrix (s2, 4, 5)),
       point_type = 4,
       color      = green,
       key        = "Sample from stations 1, 4 and 5",
         points(submatrix (s2, 2, 3)) )$

Coordinates can be given in two different list-formats.

xx: [1,2,3,4,5]$
yy: [4,5,7,1,2]$
zz: [3,2,1,9,4]$
xyz: [[10,15,12],[11,13,16],[16,10,11],[15,15,15]]$
draw3d(point_size = 3,
       point_type = filled_square,
       color      = blue,
       points(xx,yy,zz),
       point_type = circle,
       color      = green,
       points_joined = true,
       points(xyz));

Discrete data can be also joined by lines. This is an example of Brownian motion in 3d.

block([history:[[0,0,0]], lst, pos],

   for k:1 thru 10000 do
      (lst: copylist(last(history)),
       pos: random(3)+1,
       lst[pos]: lst[pos] + random(2)*2-1,
       history: endcons(lst, history) ),

   draw3d(title         = "Brownian motion in 3D",
          terminal      = eps,
          point_size    = 0,
          points_joined = true,
             points(history) )  )$


Option points_joined also accepts value impulses. (This feature was introduced in Maxima 5.15.)

draw2d(points_joined = impulses,
       line_width    = 2,
       color         = "light-blue",
       points(makelist(exp(-k/10),k,0,50)) )$

draw3d(points_joined = impulses,
       line_width    = 2,
       color         = "light-blue",
       xyplane       = 0,
       points(makelist([random(10.0),random(10.0),random(10.0)-5],k,0,25)) )$


Back to main page
Back to draw contents


by Mario Rodríguez Riotorto