previous next

This demonstrates using the myPhysicsLab library to draw graphs. The equation of the graph can be entered as JavaScript in the Terminal command line interface.

NOTE: This will only work on simple-compiled versions of this app; advanced-compiled versions cannot execute JavaScript.

This graph shows a single GraphLine. However, you can change the style (color, line width, dots vs. lines) at any time, so it can look like there are several different graphs being drawn.

To clear all points from the GraphLine:


To plot a new graph use the "plot" command. This adds points to the GraphLine, with the value for "x" going between the two given numbers. The "b" value is set by the slider control below the graph.

  plot("b*x*x", -5, 5);

You can specify the number of points plotted as the 4th argument to plot (the default is 200). To add points to the GraphLine in a new color:

  plot("-b*x*x", -5, 5, 50);

To change the area being shown (arguments are left, bottom, top, right)

  simView.setSimRect(new DoubleRect(-6, -30, 6, 30));

To change line width or drawing mode:

  plot("x", -10, 10);
  plot("-x", -10, 10);

To redraw the entire GraphLine with a different style:

Valid HTML 4.01