Graphing roles

Graphing Roles

Analytica provides a flexible way to show an array with one or many dimensions in a graph or chart by assigning values or indexes to graph graphing roles. In the simplest case of a 1-D array, you typically use only two graphing roles: The array's single index appears on the Horizontal Axis role, and the values use the Vertical Axis role. For example, here are the boiling points of the chemical elements, indexed by Symbol:


You can also use the result of another variable, say Ionization energy, as the x-axis. This differs from the preceding graph in that the horizontal axis now depicts a computed value, whereas in the preceding graph it depicts an index. Also, in the preceding graph, the depicted information is fully contained within the result of boiling point, but now information from another variable, Ionization energy, also appears. We refer to Ionization energy as a comparison variable or comparison value, since it is exogenous to the result being shown. The Definition of Boiling point does not need to be altered to include this additional information in the plot.


A graph that uses a value (rather than an index) as the horizontal axis is often referred to as a parametric plot or an XY-plot. In the header area of the result window, above the graph, several of the graphing roles appear with pulldowns that enable you to change which value or index is assigned to the graphing role. In the preceding case, a meaningful plot results because both boiling point and ionization energy share a common index, Symbol, and that index is used for the Common index role. The Horizontal Axis role also appears, but the Vertical Axis role in this case does not explicitly appear. Although it does not show, the Vertical axis role is present and is filled by Boiling point, which happens to be the only valid option for that role here, and hence a selector for the role is not shown. A Key role appears but is currently not assigned to any index or value, and hence, the graph is not showing a key. The next plot assigns the variable Classification to the Key role.


Here Classification is another comparison variable, whose result is an array indexed by Symbol, and for each symbol it contains the textual classification for that element. The graph is now depicting several pieces of information: The boiling point, the ionization energy, and the classification, as these vary along Symbol. In addition, the Symbol of the element is in there as well, viewed when you click on a point.


In the examples so far, the variable's value (Boiling point) used the Vertical Axis role, but you could also assign it to the Symbol size role. Then you can assign a yet another comparison variable (Periodic table row) to the Vertical axis role:


Graphing roles let you produce a variety of "chart types" just by assigning values or indexes to graphing roles, rather than selecting from a library of chart types. When designing a graph, it helps to think about which graphing role you want to use for each kind of information, values and indexes.

Using comparison values

When you want depict an exogenous value in your graph, you must first add it as a comparison variable. Do to this, push the XY.png button at the top-right corner of the result window (you will need to be in edit mode) to bring up the XY Comparison dialog, and add the variable to the bottom panel. Once the variable is listed, it will appear on each of the graphing role pulldowns that it applies to. Adding a comparison variable does force the information to appear on the plot, but rather it gives you the option of using that comparison variable in a graphing role.

Assigning data columns to roles

When you want to assign a single "column" of your result to one graphing role, and a different "column" to a different graphing role, then you need set the Comparison index. In Analytica, there is no intrinsic notion of any given index being the "column" index, so a more accurate terminology would be to assign a single slice of your result along some comparison index to a graphing role.

To assign individual slices to graphing roles, first turn on the comparison index by pressing the XY.png button at the top-right corner of the result window (you must be in edit mode) and then check Use comparison index. A Comparison index role then appears at the top of the result window, where you can select which index to use. Once selected, the column names appear in the role pulldowns as options.

Index Phase := Sequence(0,330,30)
Index Angle := Sequence(0,360)
Variable Signal := Sin(Angle+Phase)

To plot Signal[Phase=30] against Signal[Phase=60], use Phase as the Comparison index:


The Comparison index pulldown excludes indexes that have more that 50 elements, as these are deemed unlikely to be comparison indexes (they are almost certainly long data indexes). Also, when viewing the CDF or PDF result view for a continuous distribution, the Comparison index is always implicitly set to be the DensityIndex and cannot be changed from that result view.

Enabling graphing roles

Some graphing roles only appear after they have been enabled from the Graph setup dialog. For example, by default only a single Key option appears for symbol or symbol/line plots, but by enabling the Use separate color / symbol keys and Allow variable symbol size settings (on the Chart Type tab of the Graph setup dialog), you'll have the option of assigning separate indexes and values to the Color, Symbol and Symbol Size roles, enabling you to depict as many as six separate items on a single symbol or symbol-line plot. In a line plot with multiple varying indexes, the Common index role specifies the index that varies along a single curve, thus determining how the points are connected.

In a bar chart, roles may include the two axes, Color, Bar origin, Stacking index, and Cluster index. In a bar chart, the independent axis (the horizontal axis unless Swap horizontal and vertical is enabled) must be an index or a categorical value (i.e., not a continuous or real-valued quantity). When a categorical value is used, it is possible that multiple bars may land in a single horizontal label, and that the number of bars by be different in each horizontal label, which is allowed. Cluster index appears as a role separate from Color when a categorical value is assigned to the Color role in a stacked bar chart and varies along at least two indexes. The Bar origin role is available only after you've enabled the Variable origin setting in Graph setup.

The Color role must also be either an index or a categorical value an not a real-valued quantity. Several roles are restricted to index fillers: Common index, Stacking index, Cluster index and Symbol.

When a categorical value having two or more indexes is used for the Color role, and the Stacked setting is enabled, the Stacking index and Cluster index roles both appear.

Any index appearing as a slicer can be set «All» to make it a free index, so that all data that varies along that index appears on the plot. This enables any number of indexes to vary, and hence, many more data points to appear. If your filler for the Color role does not vary along the slicer index, then you will have multiple lines, bars or symbols with the same color, and the same holds for other roles that don't vary.

Smart pivoting

Many role-filler combinations would not produce meaningful graphs. For example, you would not want to vary Color along the Common index in a line chart, which would cause a single curve to vary its color from point to point, and make it difficult to identify that curve in the key. The result window role pivoters employ many intelligent heuristics to expose only the roles and role filler options that would result in meaningful graphs, and to adjust other roles after you make a selection so that the combination of role assignments is sensible. This often enables you to reach the desired graph quickly without having to pass through nonsense intermediate pivots.

One rule that is enforced is that the main result must be depicted in at least one role. If you haven't depicted the main result as Color or Symbol size, for example, then it is forced to be the Vertical axis, and you wouldn't be given an option of assigning a different index or value to the Vertical axis.

In a bar chart, it would be redundant to use the same index for the Horizontal Axis and the Color, but this is not a disallowed combination.


However, as you attempt to set Horizontal Axis and Color to be the same index, you may find that automatically changes Color to be different from Horizontal each time you change Horizontal, and vise versa, repeatedly "outsmarting" you in its attempt to produce the more meaningful graph. The "trick" here is to first assign it to Horizontal and set Color to blank, and then change color to the same index.

Another example

This example shows projections of U.S. energy consumption made by two organizations, the U.S. Energy Information Administration (actual) and the Alliance for Renewable Energy (fictional). The horizontal axis is set to Energy source, the key color is set to Organization, leaving the Year as a slicer, from which we have selected 2025.

Chapter7 9.png

Here we have pivoted the graph by changing graphing roles. We assign Year to the horizontal axis, Energy source to the color key, and Organization to the symbol key, leaving no need for a slicer.

Chapter7 10.png

In this version, the color key and symbol key both show the Organization index, which is therefore differentiated by both color and symbol shape. The index Energy source is not assigned a visible graphing role, so shows up as a slicer. It is set to Totals, to show total over energy sources for each organization.

Chapter7 11.png

List of available graphing roles

  • Vertical axis: The vertical direction, labeled along the left edge of the graph. By default, it shows the actual values in the array — other roles usually show values of an index. All graphs use this role, but the Vertical Axis menu only appears if you have set Swap horizontal and vertical in the Graph setup dialog or for XY graphs.
  • Horizontal axis: The horizontal direction, labeled with numbers or text along the lower edge of the graph. It always appears, except when you set Swap horizontal and vertical for a 1D array. In the table view, it becomes the column headers.
  • Common index: The index that varies from point to point along a single "curve". When the horizontal axis is an index, the common index will implicitly be the same as the horizontal index, and hence won't appear as a pulldown.
  • Key: Defines the color of lines or symbols. By default, it appears for the second index, if the array has more than one dimension. The key appears below the graph — unless reset in the Style tab of the Graph setup dialog. In the table view, it becomes the row headers.
  • Color key and Symbol key: If you check Use separate color/symbol keys in the Graph setup dialog (available for the two line styles that show symbols), it expands the key into two graphing roles, color key and symbol key. Each has its own role menu, letting you assign a second and third index.
  • Symbol size key: If you further check Allow variable symbol size, it adds symbol size as a fourth graphing role. You can specify the range of sizes from smallest to largest in typographic points, corresponding to smallest and largest values of the corresponding index. (It only works for a numerical index.) Symbol key and symbol size key do not appear in the table view.
  • Comparison index: When you want to depict multiple individual slices of your data in the same graph, you'll need to set the comparison index to the index to slice (intuitively, the "column" index). Use the XY Comparison dialog to enable the use of a comparison index first.
  • Bar origin: In a bar chart, the bars normally extend from the origin (i.e., Y=0) to the value assigned to the Vertical axis role (or to the Horizontal axis role when the Swap horizontal and vertical axes setting is enabled). When you assign a value to the bar origin role, the bars start from your computed bar origin and extend to the Vertical axis value, allowing you to depict information on each end of each bar. A stacked bar chart or stacked waterfall chart automatically varies the bar origin without you having to specify this role.
  • Stacking index: In a stacked chart, the stacking index determines the dimension of stacking. This role is often implied, particularly when an index is used for the Color role, and in such cases its role pulldown is not explicitly shown. The role pulldown will appear when multiple meaningful options exist, notably when a categorical value (not an index) is used for Color in a stacked bar chart.
  • Cluster index: An index in which varies between the columns of bars that appear within a single category along the horizontal axis. These multiple columns of bars within a single horizontal interval is called a cluster. In most clustered bar charts, the Cluster index role is implied to be the same as the key or color role, and in these cases the cluster role does not appear explicitly. When a multidimensional categorical value is assigned to the Color/Key role, then there may me multiple options for the cluster index, and in that case its role pulldown appears. See, for example, Stacked clustered bar charts.
Stacked clusters.png
  • Slicers: If the array has a dimension not assigned to a visible graphing role, it appears as a slicer — a menu above the graph. The value you select from a slicer menu applies to the entire graph, so the graph does not show values for other elements of the slicer. You can also select “Totals” from a slicer to show the total over all numerical values over that index, or "«All»" to use vary the index so that all points along that index are depicted. Slicers appear the same in the table as in the graph view. If you have more than one slicer, you can reorder them from top to bottom, in edit mode, simply by dragging a slicer up or down.

See Also


You are not allowed to post comments.