ergetgetagt

Page 107

Chapter 8: Base modules

102

string format="", explicit pen p=nullpen); Here are some simple examples of two-dimensional graphs: 1. This example draws a textbook-style graph of y = exp(x), with the y axis starting at y = 0: import graph; size(150,0); real f(real x) {return exp(x);} pair F(real x) {return (x,f(x));} xaxis("$x$"); yaxis("$y$",0); draw(graph(f,-4,2,operator ..),red); labely(1,E); label("$e^x$",F(1),SE);

y

ex 1 x 2. The next example draws a scientific-style graph with a legend. The position of the legend can be adjusted either explicitly or by using the graphical user interface xasy (see Chapter 11 [GUI], page 163). If an UnFill(real xmargin=0, real ymargin=xmargin) or Fill(pen) option is specified to add, the legend will obscure any underlying objects. Here we illustrate how to clip the portion of the picture covered by a label: import graph; size(400,200,IgnoreAspect); real Sin(real t) {return sin(2pi*t);} real Cos(real t) {return cos(2pi*t);}


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.