This example illustrates methods for continuing exploratory analysis of graph data after a graph is initially created. For this example, open the Irisdat.sta data file located in the Examples\Datasets subfolder of your STATISTICA installation folder. You can open it using the File - Open Examples menu (the data file is in the Datasets folder), the Open Data button on any Startup Panel, or the toolbar button. This data file, based on the classic example data of Fisher (1936), contains measurements made on length and width of flower parts (sepals and petals) and the corresponding iris flower type (Setosa, Versicol, and Virginic). In this example, we will explore the relationship between two of the variables: sepal length (Sepallen) and petal length (Petallen).
Producing the Graph
With Irisdat.sta open, select Scatterplots from the Graphs menu to display the 2D Scatterplots dialog.
Click the Variables button on the Quick tab of the 2D Scatterplots dialog to display the standard variable selection dialog, specify the variables for the X and Y axes as Petallen and Sepallen, respectively, and then click the OK button.
Select the Advanced tab of the 2D Scatterplots dialog and note that, by default, a Linear fit is specified for the graph.
Marking selected subsets
In order to explore possible differences in the relationship between sepal length and petal length from flower type to flower type, we would like to display the flower types separately on the graph. To do this:
Click the Mark Selected Subsets button on the Advanced tab to display the Specify Multiple Subsets dialog. In this dialog, you will specify three subsets to mark on the scatterplot.
In the Subset 1 group, select Include if and enter Iristype = 'Setosa', and in the Subset 2 group, select Include if and enter Iristype = 'Versicol'.
Finally, select Include if and enter Iristype = 'Virginic' in the Subset 3 group. The Specify Multiple Subsets dialog should look as shown below:
Click the OK button on this dialog and on the 2D Scatterplots dialog to produce the graph shown below:
Adding a new fit line
On examination of the graph, it is obvious that the linear relationship displayed is very strongly influenced by the presence of the compact group of Setosa measurements that occur at lower values of both Petallen and Sepallen. It would be of some interest perhaps to explore the relationship between these variables within the Virginic-Versicol group, which on initial examination appears to have a slightly different trend than that calculated for all flower types together. Specifically, we want to add another linear regression line to the plot that includes only the data in the Versicol and Virginic groups.
Double-click on the outer background area (i.e., the area immediately outside the scatterplot) of the graph to display the Graph Options dialog.
Next, select Plot: Fitting. In options pane, the linear fit currently applied to the graph data is designated as number 1 in the Fit box.
Click the Add new fit button to designate an additional fit.
Restricting the range of the fit
By default, this fit will be Linear as shown in the Fit type box. We will leave it as linear, although we could easily specify another fit type at this point. We want, however, to restrict this fit to the Versicol and Virginic data. Therefore:
In the Range box in the Fitting data group, change the Full Range selection to Custom Range. Inspection of the graph shows we can restrict the X range of data to values that completely exclude the Setosa group.
Enter 2.5 in the Min box and 7.5 in the Max box.
If you want the new fit to be displayed in a different pattern or color, you can choose from options available by clicking the Pattern button in the Line group.
Click the OK button at the bottom of the Graph Options dialog to redraw the graph displaying both the original and the newly specified fit lines.
Adding custom axis labels and limit lines
Now we want to display the lower and upper limits of the Versicol and Virginic data used in the new fit.
Double-click the graph margin to display the Graph Options dialog.
Select Axis: Custom Units, and in the first line of the spreadsheet area enter 2.5 in the Position column, Lower in the Text column, and select the Grid check box. In the second line enter 7.5 and Upper in the Position and Text columns, respectively, and again select the Grid check box.
Click the Gridlines button to display the Line Properties dialog, where you can designate a gridline pattern and/or color that will distinguish the new gridlines to be drawn from those already present on the graph. Then click the Close button.
Click Axis: Scale Values in the Graph Options dialog, and select the Custom labels check box in the Display scale values group.
Select the Off option button in the Skip values group in the Axis: Scale Values options pane, as well.
Close the Graph Options dialog by clicking the OK button, and the graph with the limit labels and gridlines will be displayed.
Customizing the legend
Next we will customize the legend. Double-click on the graph's outer background to once again display the Graph Options graph customization dialog. In the Graph: Titles/Text options pane, the text items associated with the graph legend can be deleted, changed, or supplemented. Note that the Graph Titles/Text dialog can also be displayed directly by double-clicking on the legend.
In the Title drop-down box in the Graph: Titles/Text options pane, select Right Title. In the window above, the legend will be displayed. To modify a legend, it must first be disconnected from the graph. Select the legend text in the window, right-click on the highlighted text, and select Disconnect Object(s) from Graph from the resulting shortcut menu. Then, shorten the text items in the legend for better readability to Setosa, Versicol, and Virginic. You can also remove the Other category, completely. See also Is all graph text editable?.
To create a legend title, place the mouse pointer on the left side of the first item (point marker symbol) on the legend, enter Flower Type, and press the ENTER key on your keyboard. Click the OK button at the bottom of the Graph Options dialog to redraw the graph.
To change properties of the symbols in the legend (i.e., point markers or fit lines) double-click on the item in the graph or access the item in the appropriate options pane of the Graph Options dialog (i.e., Plot: General to change point markers or Plot: Fitting to change the properties of the fit line). Changing the properties of these items on the graph automatically makes the changes in the legend symbols.
Changing titles and axis titles
Finally, we will change the titles and axis titles. Double-click on any graph title or axis title to display a dialog that is used to customize that title. Note that axis titles and graph titles can also be accessed from the Axis: Title and Graph Titles/Text options panes, respectively, of the Graph Options dialog.
Double-click the x-axis title to display the Title dialog where Petallen can be changed to Petal Length. The y-axis label can be changed in the same fashion (i.e., change Sepallen to Sepal Length).
Similarly, double-click the graph title to display the Graph Titles/Text dialog where the default Scatterplot (Irisdat.sta 5v*150c) can be changed to Fisher's Iris Flower Data.
The completed graph (shown above) incorporates changes to legends and titles and the addition of labels and gridlines defining the range of data incorporated into the newly added fit.