WPSML Plotting Support Chris Hector Logictran, Inc. Draft 1.1 September 16, 2005 Introduction This document provides details on WPSML 2.0 support for plotting. Revision History Draft 1.0 Draft 1.1 07/13/2005 09/16/2005 Initial draft Resolved handling of axis labels that use multiples of pi or e Elements The plotting elements in WPSML are described in this section – and specific examples are contained in the following Examples section. Algorithmic Attribute Values Plotting elements are most often used for algorithmic content, and therefore some attribute values can be algorithmic in nature. Where this occurs, the attribute values column will show the attribute type, followed by /CM indicating that this attribute can contain a Compact Math syntax which must be expanded to obtain the attribute value. chart The chart element is used for all plots. In TestGen exports, the chart element has no attributes and contains a single "plot-area" element. plot-area The plot-area element contains all of the instructions for generating a plot. It has two attributes, height and width which specify the size of the plot in pixels. The plot-area must contain one or more axis elements, along with the plot data (series, series-formula, and composites.) The type of plot (polar, cartesian, line) is determined by the axis elements contained within the plot-area. Attribute Description Values Required height width Specifies the height and width in pixels of the plot-area floating point Y axis The axis element defines the coordinate system for the plot. In a line plot, there will be a single axis, in Cartesian there are two (x and y) and in polar there is a single axis. Attribute Description Values Required class The class attribute determines the axis type and can contain the values "x" – x, y, r Y specifying the horizontal axis, "y" for the vertical axis and "r" for the polar axis. arrow-start arrow-end Indicates whether starting and ending arrows should be displayed. yes, no N, no is default visible Indicates whether the axis should be displayed. yes, no N, yes is default minimum The minimum value for the plot as displayed floating point (CM) Y maximum The maximum value for the plot as displayed floating point (CM) Y length The length of the axis in pixels. This length only refers to the plottable portion of the axis (without arrowheads and other presentational components) and is used for scaling purposes. floating point Y name A label for the axis CDATA (CM) N, default is no label logscale Set to "yes" if this axis is log scale. yes, no N, no is default tick-marks The tick-marks element defines the ticks that are displayed along the axis. They also specify any grid lines for the plot. There can be zero or more tick-marks elements within an axis. Attribute Description Values Required units Specifies the number of units represented by each tick floating point (CM) Y position Indicates the position of a single tick mark. tick-marks may contain a label floating point (CM) N sub-element with a specific label. labels Specifies the number of units before a label is displayed. If omitted no labels are displayed. floating point (CM) N, default is no label. type Specifies the tick mark type inner, outer, cross, N, default is cross none grid-line Specifies a grid line corresponding to this tick-mark none, continuous, dashed, dotted N, default is none series The series element defines a series of individual points by providing the coordinates of each point. Attribute Description Values Required name Specifies a name for the series CDATA Y visible Indicates whether the series should be displayed. yes, no N, yes is default series-formula The series-formula element defines a plotted line by providing a formula. Attribute Description Values Required name Specifies a name for the series-formula CDATA N visible Indicates whether the series-formula should be displayed. yes, no N, yes is default domain- The minimum valid value for the floating point N, negative min domain of the function. . (CM) infinity is the default domainmax The maximum valid value for the domain of the function. .. floating point (CM) N, infinity is the default template Specifies a template for the seriesformula – this is the name of a predefined template (hyperbola, circle) CDATA N, no default composite The composite element allows multiple series-formulas or composites to be AND'ed together. Attribute Description Values Required name Specifies a name for the composite CDATA Y visible Indicates whether the composite should be displayed. yes, no N, yes is default Values Required point The point element describes a single plot point. Attribute Description x-coord The x-coordinate location (line or cartesian plot) or the r value (polar plot) CDATA (CM) Y y-coord The y-coordinate location (line or cartesian plot) or the theta value (polar plot) CDATA (CM) N Examples Example 1 Simple Cartesian plot <chart> <plot-area height="200" width="200"> <axis class="x" arrow-start="yes" arrow-end="yes" visible="yes" minimum="0" maximum="5" length="160" name="t"> <tick-marks grid-line="dotted fine" units="1" labels="1"/> </axis> <axis class="y" arrow-start="yes" arrow-end="yes" visible="yes" minimum="0" maximum="600" length="162" name="t"> <tick-marks grid-line="dotted fine" units="100" labels="1"/> </axis> <series-formula> <expression>y</expression> <eq/> <expression>((v11+(x*v10))-((x^2)*16.085))</expression> </series-formula> </plot-area> </chart> 1. series-formula contains a y=f(x) expression using compact math representations. The v11, v10 in the expression element would be replaced with the correct variables for the algorithmic plot. 2. The x axis is labeled "t", and the y axis is labeled "h". Example 2 Simple Line plot with labeled points <chart> <plot-area height="40" width="238"> <axis class="x" arrow-start="yes" arrow-end="yes" visible="yes" minimum="1980" maximum="1990" length="238"> <tick-marks units="1" labels="2"/> </axis> <series name="1"> <point x-coord="1981"> <label><xhtml:div>A</xhtml:div></label> </point> <point x-coord="1982"> <label><xhtml:div>B</xhtml:div></label> </point> <point x-coord="1984"> <label><xhtml:div>C</xhtml:div></label> </point> </series> </plot-area> </chart> Example 3 Axis numbered in multiples of Pi <chart> <plot-area height="200" width="200"> <axis class="x" arrow-start="yes" arrow-end="yes" visible="yes" minimum="0" maximum="6.283" length="200"> <tick-marks position="1.57080"><label><mathml:math> <mathml:mfrac><mathml:mrow><mathml:mn>Π</mathml:mn></mathml:mrow> <mathml:mrow><mathml:mn>2</mathml:mn></mathml:mrow> </mathml:mfrac></mathml:math></label></tick-marks> <tick-marks position="3.1416"><label>Π</label> </tick-marks> <tick-marks position="4.71238"><label><mathml:math> <mathml:mfrac><mathml:mrow><mathml:mn>3Π</mathml:mn></mathml:mrow> <mathml:mrow><mathml:mn>2</mathml:mn></mathml:mrow> </mathml:mfrac></mathml:math></label></tick-marks> </axis> <series-formula> <expression>y</expression> <eq/> <expression>v1*cos(pi/2)</expression> </series-formula> </plot-area> </chart> In problem 1-5, the labels on the axis are expressed in terms of fractions of pi. This is specified by providing the tick marks and labels explicitly. The position attribute of tick-marks specifies a location, and the label sub-element provides the corresponding label. Example 4 axis with omitted portion <axis class="y" minimum="450" maximum="600" ... Notes: In problem 1-4, the y axis has an omitted section. The spelling of this is <axis class="y" minimum="450" maximum="600" ... Example 5 Composite plot <composite fill-pattern="horizontal"> <series-formula> <expression>y</expression> <geq/> <expression>1/2*x-1</expression> </series-formula> <series-formula> <expression>y</expression> <leq/> <expression>-x</expression> </series-formula> </composite> Notes: The plotting of a composite contains the AND'ed result of the two inequalities. Composites can contain other composites. Example 6 Polar plot <chart> <plot-area ...> <axis class="r" ...> <!-- only one axis, marked as class="r" --> <tick-marks .../> </axis> <series-formula> <expression>r</expression> <eq/> <expression>v1*sin(v2*t)</expression> theta as variable name --> </series-formula> </plot-area> </chart> Example 6 Hyperbola plot <!-- use t rather than <chart> <plot-area ...> <axis class="x" ...> <tick-marks .../> </axis> <axis class="y" ...> <tick-marks .../> </axis> <series-formula template="hyperbola_a"> <expression>1</expression> <eq/> <expression>y^2/v3^2-x^2/v4^2</expression> </series-formula> </plot-area> </chart> Note that the template attribute is only provided as a hint and is not required.