Graphics in Axiom
The graphics commands are described in Chapter 7 of the AxiomBook.
The syntax is:
draw(f(x), x=a..b, options)
draw(f(x,y), x=a..b, y=c..d, options)
axiom
vp1:=draw(sin(x), x=%pi/10..%pi)
axiom
Compiling function %B with type DoubleFloat -> DoubleFloat
Graph data being transmitted to the viewport manager...
FriCAS2D data being transmitted to the viewport manager...
Type: TwoDimensionalViewport
?
This command creates a "view port" and would normally (on linux for
example) also display the graph.
The draw command works only under an X-Windows environment
(unix/linux). Work is underway to create a new user interface
(AxiomUI) that among other things will allow graphics to be
viewed under other operating systems. If you're interested in
graphics, please pitch in!
Although due to technical limitations of this system (no Xwindows
environment on the Web server) we are not yet able to display
the graph here. However we description below a similar command
named gnuDraw that can be used to generate similar graphics on
this web site.
gnuDraw
It is possible to produce graphics similar to Axioms using
gnuplot on this web site. To do this you need to include the
GnuDraw (GDRAW) library
axiom
)lib GDRAW
GnuDraw is now explicitly exposed in frame initial
GnuDraw will be automatically loaded when needed from
/var/zope2/var/LatexWiki/GDRAW.NRLIB/code
The following examples are taken from Chapter 7 Graphics of
the AxiomBook.
Section: 7.1 Two-Dimensional Graphics
The general format for drawing a function defined by a formula
f(x) is:
gnudraw(f(x), x = a..b, "filename.dat", options)
where a..b defines the range of x, options are additional
draw options and "filename.dat" will contain the gnuplot
script necessary to create the graph.
axiom
gnuDraw(sin(x), x=%pi/10..%pi,"AxiomGraphics1.dat")
axiom
Compiling function %F with type DoubleFloat -> DoubleFloat
Graph data being transmitted to the viewport manager...
FriCAS2D data being transmitted to the viewport manager...
Type: Void
This file may be displayed on the web page using:
!/begin{gnuplot}
load "filename.dat"
/end{gnuplot}

Technical Details
We can extract the graph data from the view port. For example
we can display the list of data points that would be plotted in
the graph.
(Note: we disable LaTeX output typesetting in order to save
space.)
axiom
)set output tex off
axiom
)set output algebra on
g1:=getGraph(vp1,1)
(3) Graph with 1 point list
axiom
pointLists(g1)
(4)
[
[[0.31415926535897931,0.3090169943749474,1.0,3.0],
[0.37306412761378793,0.36447049987914965,1.0,3.0],
[0.43196898986859655,0.41865973753742808,1.0,3.0],
[0.49087385212340517,0.47139673682599764,1.0,3.0],
[0.5497787143782138,0.5224985647159488,1.0,3.0],
[0.60868357663302242,0.57178796022761225,1.0,3.0],
[0.66758843888783104,0.61909394930983397,1.0,3.0],
[0.72649330114263966,0.66425243791128175,1.0,3.0],
[0.78539816339744828,0.70710678118654746,1.0,3.0],
[0.8443030256522569,0.74750832686259672,1.0,3.0],
[0.90320788790706552,0.78531693088074495,1.0,3.0],
[0.96211275016187414,0.82040144352551359,1.0,3.0],
[1.0210176124166828,0.85264016435409218,1.0,3.0],
[1.0799224746714913,0.88192126434835494,1.0,3.0],
[1.1388273369262998,0.90814317382508114,1.0,3.0],
[1.1977321991811083,0.93121493475880346,1.0,3.0],
[1.2566370614359168,0.95105651629515342,1.0,3.0],
[1.3155419236907253,0.96759909236025965,1.0,3.0],
[1.3744467859455338,0.98078528040323032,1.0,3.0],
[1.4333516482003423,0.99056934044357714,1.0,3.0],
[1.4922565104551508,0.99691733373312785,1.0,3.0],
[1.5511613727099594,0.99980724048206482,1.0,3.0],
[1.6100662349647679,0.99922903624072301,1.0,3.0],
[1.6689710972195764,0.99518472667219704,1.0,3.0],
[1.7278759594743849,0.98768834059513799,1.0,3.0],
[1.7867808217291934,0.97676588132087272,1.0,3.0],
[1.8456856839840019,0.96245523645364772,1.0,3.0],
[1.9045905462388104,0.9448060464668786,1.0,3.0],
[1.9634954084936189,0.92387953251128752,1.0,3.0],
[2.0224002707484274,0.89974828405222229,1.0,3.0],
[2.0813051330032359,0.87249600707279817,1.0,3.0],
[2.1402099952580445,0.84221723371628776,1.0,3.0],
[2.199114857512853,0.80901699437494878,1.0,3.0],
[2.2580197197676615,0.77301045336273855,1.0,3.0],
[2.31692458202247,0.73432250943568722,1.0,3.0],
[2.3758294442772785,0.69308736254563774,1.0,3.0],
[2.434734306532087,0.64944804833018577,1.0,3.0],
[2.4936391687868955,0.60355594195357376,1.0,3.0],
[2.552544031041704,0.55557023301960473,1.0,3.0],
[2.6114488932965125,0.50565737337798722,1.0,3.0],
[2.670353755551321,0.45399049973954964,1.0,3.0],
[2.7292586178061295,0.40074883310314402,1.0,3.0],
[2.7881634800609381,0.34611705707749618,1.0,3.0],
[2.8470683423157466,0.29028467725446577,1.0,3.0],
[2.9059732045705551,0.23344536385590897,1.0,3.0],
[2.9648780668253636,0.17579627993435823,1.0,3.0],
[3.0237829290801721,0.11753739745784152,1.0,3.0],
[3.0826877913349806,0.058870803651193036,1.0,3.0],
[3.1415926535897931,1.2246467991473532E-16,1.0,3.0]]
]
Type: List List Point DoubleFloat
?
axiom
)set output algebra off
axiom
)set output tex on
Using lower level functions the points in such a graph can also
be constructed as follows:
First we need this domain
axiom
)expose GraphImage GraphImage is now explicitly exposed in frame initial
axiom
lineSegments := [[point [sin(x*%pi/10)$DoubleFloat, _
x*%pi/10], point [sin((x+1)*%pi/10)$DoubleFloat, _
(x+1)*%pi/10]] for x in 1..10]
Type: List List Point DoubleFloat
?
axiom
lineColors := [light blue() for i in 1..10]
Type: List Palette
axiom
pointColors := [dark blue() for i in 1..10]
Type: List Palette
axiom
lineSize := [6 for i in 1..10]
axiom
g2:=makeGraphImage(lineSegments, lineColors, pointColors, lineSize)
Graph data being transmitted to the viewport manager...
axiom
)set output tex off
axiom
)set output algebra on
pointLists(g2)
(10)
[
[[0.3090169943749474,0.31415926535897931,22.0,5.0],
[0.58778525229247314,0.62831853071795862,22.0,5.0]]
,
[[0.58778525229247314,0.62831853071795862,22.0,5.0],
[0.80901699437494745,0.94247779607693793,22.0,5.0]]
,
[[0.80901699437494745,0.94247779607693793,22.0,5.0],
[0.95105651629515353,1.2566370614359172,22.0,5.0]]
,
[[0.95105651629515353,1.2566370614359172,22.0,5.0],
[1.0,1.5707963267948966,22.0,5.0]]
,
[[1.0,1.5707963267948966,22.0,5.0],
[0.95105651629515364,1.8849555921538759,22.0,5.0]]
,
[[0.95105651629515364,1.8849555921538759,22.0,5.0],
[0.80901699437494745,2.1991148575128552,22.0,5.0]]
,
[[0.80901699437494745,2.1991148575128552,22.0,5.0],
[0.58778525229247325,2.5132741228718345,22.0,5.0]]
,
[[0.58778525229247325,2.5132741228718345,22.0,5.0],
[0.30901699437494751,2.8274333882308138,22.0,5.0]]
,
[[0.30901699437494751,2.8274333882308138,22.0,5.0],
[1.2246467991473532E-16,3.1415926535897931,22.0,5.0]]
,
[[1.2246467991473532E-16,3.1415926535897931,22.0,5.0],
[- 0.3090169943749469,3.455751918948772,22.0,5.0]]
]
Type: List List Point DoubleFloat
?
axiom
)set output algebra off
axiom
)set output tex on