Size and Colours

Page Contents

Changing The Size Of The Window

If nothing else is specified, MathymaGraph will draw the graph in a 360 x 360 pixel window. To change this, write the size of the window you want, width x height in pixels, when creating the graph:

   var wGraph = new mathyma.Graph(150,200);
   wGraph.drawPolygon("1,6,3,10,6,2,5,1,1,3",true)
   wGraph.printInWindow();

If you want to print the graph twice on your page, but with a different window size, you can do this with setWindow.

   var myWin=window.open('','', ...
   ...
   var wGraph = new mathyma.Graph(150,200);
   wGraph.drawPolygon("1,6,3,10,6,2,5,1,1,3",true)
   wGraph.print(myWin);
   wGraph.setWindow(300,400)
   wGraph.print(myWin);
   ...

Just remember that if you are drawing other graphs in between, they must be given a different name.

   var GraphA = new mathyma.Graph(150,200);
   GraphA.drawPolygon("1,6,3,10,6,2,5,1,1,3",true)
   GraphA.printInWindow();
   .
   var Graph_2 = new mathyma.Graph();
   Graph_2.drawFunction("5*cos(4*x)",-2,5)
   Graph_2.printInWindow();
   .
   GraphA.setWindow(300,400)
   GraphA.printInWindow();

Overlaying Drawings

MathymaGraph does not restrict you to one drawing. Only the processing speed of your computer limits the number of drawings

   var wGraph = new mathyma.Graph();
   wGraph.drawFunction("5*cos(2*x)",-2,5)
   wGraph.drawStep("5*cos(2*x)",0.5,"",-2,5)
   wGraph.drawPolygon("1,6,3,10,6,2,5,1,1,3",true)
   wGraph.printInWindow();

Because the graph can be printed several times, you can overlay progressively, as here:

   var myWin=window.open('','', . . .
   . . .
   var wGraph = new mathyma.Graph(200,200);
   wGraph.drawFunction("5*cos(2*x)",-2,5)
   wGraph.print(myWin);
   wGraph.drawStep("5*cos(2*x)",0.5,"",-2,5)
   wGraph.print(myWin);
   wGraph.drawPolygon("1,6,3,10,6,2,5,1,1,3",true)
   wGraph.print(myWin);
   . . .

Note that the last graph has been squashed a bit to accomodate the polygon. To learn how to control this, read the page on Range and Axes

Colours

You may have noticed that MathymaGraph prints the drawings in various colours. The default colour sequence is blue, red, green, violet, orange, yellow, cyan, black, blue, red. Anything after that is printed in grey. You can change this sequence by using setColours (American readers please note the spelling - but you can use setColors instead):

   var wGraph = new mathyma.Graph(400,200);
   wGraph.drawFunction("cos(Math.PI*x)",-3,3);
   wGraph.drawFunction("cos(Math.PI*x-1)",-3,3);
   wGraph.drawFunction("cos(Math.PI*x-2)",-3,3);
   wGraph.setColours("blue,green,cyan");
   wGraph.printInWindow();

You can reprint your graph in different colours without rewriting the whole thing:

   var myWin=window.open('','', ...
     .
   var wGraph = new mathyma.Graph(400,200);
   wGraph.drawFunction("cos(Math.PI*x)",-3,3);
   wGraph.drawFunction("cos(Math.PI*x-1)",-3,3);
   wGraph.drawFunction("cos(Math.PI*x-2)",-3,3);
   wGraph.setColours("blue,green,cyan");
   wGraph.print(myWin);
   wGraph.setColours("red,orange,red");
   wGraph.print(myWin);
      .

The colours you can use are: red, orange, yellow, green, cyan, blue, violet, grey, black, and white (that's right - white!).