Tutorial 5. Manipulating Axes, Legend, and Titles
In this tutorial, we will learn about manipulating graph axes, legend, and
titles. It is
recommended that you read the topics Graph Document, Property
Grid, and Series before continue.
Series Axis Association
Open the file ExamplesSample GraphsLines.dts under the DataScene
installation folder (which can be opened by selecting the Help: Demo Projects
menu command). Select the Line graph
document. Change its view dimension to 3D in the View
Dimension combo-box.
Double click the blue line (line1 as shown in the Series
Editor or J0(x) as shown in the
legend) in the Line graph document to open the Series
Editor. In the editor, select the Axes property in the property grid and
open the Series Axes dialog box by clicking
the button
in the value cell. In the Series Axes dialog box, select Bottom and Top in the Horizontal
Axis combo-box. Close the popup information window. Close the Series Axes dialog box
by clicking its OK button.
Select line2 (the red line, or J1(x) as shown in the
legend) in the Series
Editor to make it the active series. Follow the same steps as shown
above to change the axis association for line2 as: Right
for the Vertical Axis, and Bottom for the Horizontal Axis
(unchanged). Close the Series Axes dialog
box and then
the Series
Editor. The Left, Right, Top, and Bottom axes are
now all drawn in the Line graph
(as shown in Fig. 1.) because all of them are now associated with series in the
graph.

Fig. 1. The Left, Right, Top, and Bottom axes are associated with series
in the graph.
Select line3 (the green line, or J2(x) as shown in the
legend) in the Active Series
combo-box. Switch to the Graph tab-page of the Navigator
and uncheck the checkbox before line1 to hide it from the graph document.
Note that the Top axis is also hidden as line1 is hidden. This is because the
Top
axis is associated only with line1 but not with the
other series in the graph. Uncheck the checkbox before line2 to
hide it from the graph document. You will see that the Right axis is also hidden
for the same reason. Now re-check both line1 and line2 so that
they are re-drawn in the graph document.
Axis Properties
Axis properties are mainly changed with the Axis
Editor that can be opened by double clicking on the axis or by
selecting the Axes menu command on the Graph menu. Few properties can also be changed with certain tools
on the Graph
Tools tab of the ToolBox (e.g the axis
range can be changed with the Magnifier, Pan Tool, and Auto
Scale tools).
Double click the Right axis of the graph in the Line graph document to
open the Axis Editor.
Switch to the Scales tab-page of the editor, uncheck the Automatic
check box and input the following
values: 0.3 in the Desired Increment text box, 0.6 in the Maximum Value
textbox, and -0.6 in the Minimum Value textbox. On the Labels:
Style tab-page, input 45 in the Angle textbox.

Fig. 2. Customizing the Right axis with the Axis Editor.
Now, select Left Axis in the Axes list box so that we can
customize the Left axis of the graph. On the Ticks tab-page, click the Major
Grid button to open the Pen Editor.
In the editor, uncheck the Visible
check box to hide the major grids of the Left axis. Close the Pen
Editor by clicking its OK button. Switch to the Labels: Format
tab-page, select 0.00E-0 in the Values Format combo-box and check
the Exponential check box. The value 0.00E-0 is a Value
Format Code that dictates the use of the scientific notation with two
digits after the decimal point.
Checking the Exponential check box makes DataScene use "´10"
rather than "E" to represent the base and use superscript for the
exponent. Close the Axis
Editor and the Line graph document should look like that shown
in Fig. 3.

Fig. 3. The Line graph document with customized Left and Right axes.
Click the Magnifier tool on the ToolBox.
Move the mouse pointer into the graph and drag to draw a
rectangle while keeping the left mouse button pressed.
DataScene changes the range settings of the axes to zoom in the drawn
rectangle. Click the Auto Scale tool to restore all axes to
the auto-scale mode.
You may want to experiment with more properties in the Axis
Editor or the Panel Tool on the ToolBox. After you are done, close the project without
saving the changes made to it.
Legend
Use the data in the file ExamplesDataLines.txt under the DataScene
installation folder to plot three 3D Line series
in the same graph: 3DLine1 using Column 1 and Column 2, 3DLine2
using Column 1 and Column 3, and 3DLine3 using Column 1 and
Column 4. In all cases, Column 1 is associated with the Position
component and the other column with the value component. DataScene names the graph document Lines.txt. You may want to refer to Tutorial
3 for details of creating multiple series in the same graph.
The newly created graph should look like that in Fig. 4.

Fig. 4. Three 3D Line series created with data in Lines.txt.
Open the Legend Editor for the Lines.txt graph
document by double clicking on the legend or by selecting the Legend
menu command on the Graph menu. Switch to the Position
tab-page of the Legend Editor, check
different radio buttons in the Position group box to change the legend
position style (i.e. Left, Top, Right, or Bottom). You may also
use the Margin
and Position Offset properties to fine tune the legend position.
Now check the Custom check box to make the legend a custom legend. A
custom legend can be drawn inside the graph cube and can be
dragged by the mouse - which cannot be done with a non-custom legend. Change the options in
the Position group box and you will see that a Left-
or Right-style custom legend lists its legend items from top to bottom while a Top- or
Bottom-style custom legend lists its legend items from left to right. Click the OK
button to close the Legend Editor. Drag
the legend with the left mouse button to a desired position.
Open the Legend Editor again and
switch to the Labels tab-page. Make sure that 3DLine1 is selected
in the Series combo-box. In the rich text editor on the bottom of this
tab-page, erase the text "3DLine1" and type "J0(x)".
Note that the "0" is made subscript by selecting it in the editor and
then apply the subscript style by clicking the
button on the editor toolbar. This changes the legend label string for the 3DLine1
series to be "J0(x)". Note that the Name property of
the 3DLine1 series is still the plain text "3DLine1" which can be changed
with the Series
Editor.
Select 3DLine2 in the Series combo-box and change its label to
"J1(x)". Do the same for 3DLine3 and change its
label to "J2(x)". Close the Legend
Editor by clicking its OK button. The graph should like similar
to that of Fig.
5.

Fig. 5. Three 3D Line series with a customized legend.
Graph Titles
Open the Title Editor for the Lines.txt
graph document by double clicking on the "Lines.txt" header text on
the top of the graph or by selecting the Titles menu command on the Graph
menu. Make sure that Header is selected in the Title
combo-box and then select the Text tab-page. In the rich text editor of this tab-page, erase
the text "Lines.txt" and type "Bessel Functions of the First
Kind". Apply the Bold style by selecting the text and then clicking
the button.
Switch to the Frame tab-page of the Title
Editor and uncheck the Transparent
check box. Click the Brush button to open the Brush
Editor. Select the white color in the Brush
Editor and then close it by clicking its OK button. Close the Title
Editor button by clicking its OK button. The graph now should look like
that shown in Fig. 6.
Fig. 6. Three 3D Line series with customized legend and header.
You may want to experiment more options in the Legend
Editor and/or Title Editor. Close
all opened projects without saving any changes.
See Also
|