Products | Versions |
---|---|
Spotfire Statistica | 13.1 and higher |
When trying to plot a graph with numeric/double variables, you may have some value containing text strings, such as "100" and ect. Those text strings are placed in the axis based on its underlying numeric value, which depends on the order the text string enters in. The first entered text string will be assigned to '101' by default. However, you may want to put those data points in a position more representative of its real numeric value on the scale.
This article shows an example of such a scenario. A modified version of the Weather report data was used for illustration purpose. The original data excel file can be found in Statistica Example Datasets folder. This data has four columns including "Date", "Location", "Temperature" and "Condition". To demonstrate this example, the variable "Temperature" is changed to a "Text" type column and any cell with value less then 80 is recoded as "< 80" in the input data.
1. Click Home|New|Workspace to create a new blank workspace.
2. Click "Cancel" under the "Select Data Source" dialog.
3.In the new workspace, type "Import Excel" in the "Feature Finder" box to insert the "Import Excel" node into the workspace. Note: you can also find this node under Data|Get External Data or in Node Browser.
4. After the "Import Excel" node is inserted, click "Edit Parameters" (the wheel icon on top left of the node) to open the node dialog and then click "File" under the prompted configuration dialog to select the path of input excel file. Click "Ok".
5. Click "run to node" (the green arrow icon on bottom left of the node). After running the node, click "View Document" (the page icon on bottom right of the node) to view the imported data.
6. In the "Feature Finder" box, search and find "Variable Format/Rename" node to insert it into the workspace.
7. Connect these two nodes by holding the mouse left key to dragging a line between them.
8. Click "Edit Parameters" of the Variable Format/Rename node and then click "Edit Variable Specifications" under the configuration dialog.
9. Click "All Specs..." under the Variable specification dialog.
10. Change the Temperature variable type from "Text" to "Double" and click Ok"'.
11. Click "OK" under the "Variable Format/Rename" configuration dialog and run the node to make the change effective.
12. Click "View Document" of the node to view the data spreadsheet, and then double click the "Temperature" variable in the spreadsheet to access its variable specification.
13. Under the variable specification dialog, the variable type is now displayed as "Double". The following steps introduce how to recode the text strings to other numeric value such as "79". (Note: The default coding of Statistica assigns a numeric '101' to the text label "
14. In the "Feature Finder" box, search and insert "Recode Variables" node into the workspace and connect it with the "Variable Format/Rename" node. Click "Edit Parameters" to open the configuration dialog.
15. Under the "Recode Variable" configuration node, click "Select Variable" to select "Temperature" and then click "Define" to specify the recoding conditions shown as the second figure underneath. Click "Ok" after the recoding conditions are specified and click "Ok" again under the Recode Variable configuration dialog.
16. Run the "Recode Variable" node. All cells with a text string of "<80" now have numeric value of 79.
17. Now you can start to make the graph. For instance, in the "Feature Finder" box, search and insert "2D Line Plots" into the workspace and connect it with previous node.
18. Click "Edit Parameters" of the graph node to open the configuration dialog and then click "Variables" to select "Temperature". Keep other options at default and click "OK".
Â
19. Run the graph node and a "Reporting Documents" node containing the graph result will be generated in workspace.
20. Click the "Reporting Documents" node to view the graph. Data points with a value of 79 at the Y axis are actually representing those with "<80" text lables
21. If you want to label those data points with "<80", right click the graph node and select "Customize outputs" option
22. Under the Node Customizations dialog, highlight "Line Plot of Temperature" and click "Record Customization Script..."
23. When the Graph Options dialog is prompted, under Axis|Scale Values, change the Axis to "Y left", deselect "Automatic - at major tickmarks", select "Data values" and "Use text labels from data set" under the Display scale values options.
24. Click "Edit custom labels..." again under the Display scale values options(shown as above) to be redirected to "Custom Units" tab.
25. Under Custom Units tab, make sure "Y left" is selected as the Axis. Enter "79" under Position column and "<80" under Text column
26. Give a name to the recorded script (e.g. "Custom_Y_Units") and click "OK".
st
27. The script file that records steps of your customized graph options will now appear underneath the "Line Plot of Temperature". Click "Apply" and close the dialog.
28. Run the graph node again in the workspace and view the result in the reporting document. Now the graph is updated to show the customized label "<80"
29. Close the reporting documents. Under Home tab, click "Save" to save the entire workspace.