' ******************************************************************
' This program plots a function in either linear or logarithmic
' coordinates.
' ******************************************************************

#INCLUDE "fbgfx.bi"
#INCLUDE "fbmath.bi"

FUNCTION Func(X AS DOUBLE) AS DOUBLE
' Square root function (becomes linear in log-log coordinates)
  Func = SQR(X)
END FUNCTION

' Plot in linear coordinates, using default parameter values

IF NOT InitScreen THEN STOP

InitGraph

SetOxScale
SetOyScale

PlotOxAxis
PlotOyAxis

PlotGrid

WriteTitles "SQUARE ROOT FUNCTION IN LINEAR COORDINATES", "X", "Y"

SetClipping

COLOR 12

PlotFunc @Func

CloseGraph

PRINT "Press a key... "; : SLEEP

' Plot in logarithmic coordinates

IF NOT InitScreen THEN STOP

InitGraph

SetOxScale LogScale, 0.01, 100
SetOyScale LogScale, 0.1, 10

PlotOxAxis 0.1
PlotOyAxis 0.01

PlotGrid

WriteTitles "SQUARE ROOT FUNCTION IN LOGARITHMIC COORDINATES", "X", "Y"

SetClipping

COLOR 1

PlotFunc @Func

CloseGraph

