4.4. Plots

The data that multigraph draws into the plot area is organized into one or more "plots". A plot consists of a selection (usually two) of variables to be plotted, along with information about which axes to plot them along, and the style, color, and other visual attributes of the plot.

A plot is described with the plot element in the mugl file. There can be any number (zero or more) of plot elements in the file. Multigraph will draw the plots in the order they appear in the mugl file. If no plot element is present at all, multigraph creates a single line plot of the data section's first variable on the horizontal axis against the second variable on the vertical axis (or first vertical axis, if there is more than one).

The plot element takes no attributes, and the following subelements:

horizontalaxis

The horizontalaxis element indicates which variable should be mapped to the horizontal axis in the plot. It has no attributes, and takes a sequence of variable subelements. Each variable subelements has a single attribute named ref whose value should be the id of a variable from the data section. Most plots have just one variable corresponding to the horizontal axis. If a plot has no horizontalaxis element, it defaults to using the first variable from the data along the horizontal axis.

verticalaxis

The verticalaxis subelement indicates which variable(s) should be mapped to the vertical axis in the plot. It has a single attribute named ref whose value is the id of one of the verticalaxis elements specified earlier in the file. If this attribute is missing, or if The verticalaxis subelement is missing altogether, the plot will use the first vertical axis mentioned in the file (or a default one if none is mentioned). The verticalaxis subelement takes a sequence of variable subelements. Each variable subelement has a single attribute named ref whose value should be the id of a variable from the data section. Most plots have just one variable corresponding to the vertical axis, but some may have more than one. For example, a plot with error bars would have two "vertical axis" variables: one for the value, and another for the error amount. If a plot has no verticalaxis element, or a verticalaxis with no variable subelements, it defaults to using the second variable from the data along the vertical axis.

renderer

The renderer subelement specifies the graph style to be used for the plot. "Renderers" are objects in the multigraph software that are responsible for drawing data plots. Each renderer corresponds to a specific plot style, such as points, lines, bars, and so on. The renderer subelement has one attribute named type, whose value indicates the choice of renderer. New renderers that implement new plot styles can easily be added to multigraph; Section 5.1, “Adding New Renderers” describes how to do this.

Each renderer may have options that can be specified to customize its behavior. Options control things like color, line thickness, and other visual aspects of the plot. Each option is given with a option subelement of the renderer element. Each option takes two attributes: name and value, which give the name and value for that option.

At the time of this writing the supported renderers are:

KeywordDescriptionOptions
line Standard line plot with optional dots at data points
  • linecolor: color to be used for the lines
  • linewidth: width for lines
  • dotcolor: color to be used for the dots
  • dotsize: size for dots; default is 0, which means draw no dots
bar Standard bar graph
  • barwidth: the width of each bar, in pixels
  • baroffset: the offset of the left edge of each bar from the corresponding data value
  • fillcolor: the color to be used for the fill inside each bar
  • linecolor: the color to be used for the outline around each bar
fill Plot lines connecting data points, with a solid fill between the lines and the horizontal axis
  • linecolor: the color to be used for the lines
  • linethickness: the thickness of the lines, in pixels
  • fillcolor: the color to be used for the fill area
  • fillopacity: the opacity to be used for the fill area
point Standard point plot with optional shapes (circle, square, triangle)
  • shape: shape of the point (circle, square, triangle)
  • linecolor: color to be used for the lines
  • linethickness: the thickness of the line around the drawn point
  • color: color to be used for filling the points
  • size: size of the points (radius or width)
  • fillopacity: the opacity of the filled color (0-1)
lineerror Standard line plot with optional dots at data points
  • linecolor: color to be used for the lines
  • linewidth: width for lines
  • dotcolor: color to be used for the dots
  • dotsize: size for dots; default is 0, which means draw no dots
barerror Standard bar graph
  • barwidth: the width of each bar, in pixels
  • baroffset: the offset of the left edge of each bar from the corresponding data value
  • fillcolor: the color to be used for the fill inside each bar
  • linecolor: the color to be used for the outline around each bar

It is possible that new renderers will have been added to multigraph since this documentation was written. You can generate a list of the current renderers that your copy of multigraph knows about, and the options they support, by writing an HTML file that creates a MultigraphRendererList instance as follows:

Example 4.2. Generating a List of Currently Supported Renderers


<html>
  <head>
    <script src="Multigraph.js"></script>
  </head>
  <body onload="new MultigraphRendererList('mydiv');">
    <div id="mydiv"/>
  </body>
</html>


To see the list of renderers available for the current copy of multigraph that is available from www.multigraph.org, visit the web page http://www.multigraph.org/renderers.