Skip to content
Hunter Close edited this page Aug 15, 2018 · 8 revisions

Graphs are used to display information on a two-dimensional Cartesian graph.

Making a Graph

To produce a graph with plotted data requires three steps in GlowScript:

  1. Create a graph display, or graphic space with axes and labels
  2. Create a series (in the form of a curve or sequence of dots) to represent the data
  3. Plot the data

graph display

First, click on the graph display block and drag it into the workspace.

graph display block

The graph display block is pre-loaded with a graph block, since the graph display will not appear until some data is plotted on a graph.

Next, click on the (+) sign to see the menu of attributes for the graph display.

graph display menu

Drag the attributes that you would like to edit over into the white space beneath display and attach them to the bottom of the chain. In this example, all of the attributes have been brought over to illustrate the default values for the attributes.

graph display block full

set series

The series block has a drop-down menu that shows two options for the line style of the graph: curve and dots.

graph menu

On the far right end is also a color picker that can be used to select the color for the individual graph. White is the default but is not recommended, as the background color for the graph display is also white.

graph color picker

plot

The plot block has two main components:

  1. Two number inputs for the x and y values that will be plotted
  2. A drop-down menu for selecting the graph on which the data will be plotted. This menu is auto-populated with the graphs that the user has already created.

In this example, the user has already created four graphs: MyGraph1, MyGraph2, MyGraph3, and MyGraph4.

plot block menu

plotting multiple points on one graph

To plot multiple points on one graph, either use multiple plot blocks:

multiple points one graph

or use a loop:

count with plot

Multiple graphs on one set of axes

Additional series blocks can be added underneath the series block that was included in the graph display block, if the user wants to display more than one graph on one set of axes.

one display two graphs

Multiple graphs on multiple sets of axes

In this example, two displays will be created, "MyGraphPaperA" and "MyGraphPaperB", with two graphs on A, and two more graphs on B.

two displays four graphs