! Demo about plotting functions. ! Author: Francois Tonneau size 10 7 set font ss ! We use a 'begin graph ... end graph' block to plot two simple mathematical ! functions. begin graph ! The effect of the 'math' command is that axes cross at point (0, 0) and ! that axis ticks extend on both sides of the axis. math ! Regardless of the 'math' command, there are many ways to customize axes ! in GLE. Here we specify the minimum, maximum, and numerical distance ! between ticks for the x axis. We also specify tick length and remove ! subticks from all axes. Anything about axes that is not customized ! assumes default values. xaxis min -3 max 3 dticks 1 ticks length 0.08 subticks off ! The 'let' command allows us to define datasets as mathematical functions ! (i.e., expressions of x) instead of values loaded from a data file. The ! defining expressions may include parentheses and usual math operators, ! but must be written without spaces. let d1 = (1/4)*(x^2) let d2 = 3*sin(x) ! Now we can plot our previously defined datasets: d1 line color cadetblue lwidth 0.03 d2 line color indianred lwidth 0.03 end graph ! We add descriptions of our functions to the plot. GLE has a variety of text ! formatting operators, such as the '^{...}' operator to produce superscript: amove 0.6 5.6 write "y = 0.25 x^{2}" amove 6 6.25 write "y = 3 sin(x)" ! Done. We have learned about function plotting and about the math mode of axis ! customization.