Skip to content
Matthias Görges edited this page May 11, 2015 · 1 revision

glgui-plot adds an XY plot (or multiple XY plots) to the screen.

Note: When x or y values change, the entire texture is recreated. This is computationally expensive! Hence if only a single value (or a small list of values) are added frequently, consider using (glgui-trace g x y w h trace color . lim) instead!

Parameter Description
g The Graphical User Interface (GUI) this widget belongs to
x Lower left corner along the x-axis in pixels
y Lower left corner along the y-axis in pixels
w Width of the widget in pixels
h Height of the widget in pixels
xval List (or list of lists) of x-values to be plotted
yval List (or list of lists) of y-values to be plotted
color Dot color (or list of colors)
lines Connect dots with lines, as boolean (or list of booleans)
axis Optional: Axis limits '(xmin xmax ymin ymax)

Example

Example 1: Draw a mixed plot, combining both a Green lineplot, with a Red scatterplot superimposed. Axis are limited to x: -10 to 10 and y: -10 to 10.

(let* ((w (glgui-width-get))
       (h (glgui-height-get))
       (dim (min (/ w 2) (/ h 2)))
       (x (list 0 1 2 3 4 5 5 6 7 8))
       (y (list 9 8 7 5 4 3 0 2 3 1))
      )
  (glgui-plot gui 300 300 300 300 (list x y) (list y x) (list Green Red) 
    (list #t #f) (list -10 10 -10 10))
)  

Attributes

Besides the parameters set in the above procedure, the widget has the following attributes that can be set using glgui-widget-set! and retrieved using glgui-widget-get:

Attribute Default Value Description
axiscolor (color-fade White 0.25) Color of x and y axis, drawn if axis are set
Clone this wiki locally