Axis Title

The AxisTitle node controls the titling of an axis. The drawing of this node is controlled by the Text Attributes.

Axes are titled with the value of the Title attribute in the AxisTitle node. By default, the title is empty.

Setting the Title

To set an axis title, set the Title attribute in the AxisTitle node. In this exam­ple both the x-axis and y-axis titles are set.

(Download Code)

 

using Imsl.Chart2D;

 

public class SampleAxisTitle : FrameChart {

 

    public SampleAxisTitle() {

        Chart chart = this.Chart;

        AxisXY axis = new AxisXY(chart);

        double[] y = {4, 2, 3, 9};

        Data data = new Data(axis, y);

 

        axis.AxisX.AxisTitle.SetTitle("The X Axis");

        axis.AxisY.AxisTitle.SetTitle("The Y Axis");

    }

 

    public static void Main(string[] argv) {

        System.Windows.Forms.Application.Run(new SampleAxisTitle());

    }

}

 

More Formatting

An axis title, like any other text string, can have further formatting applied.

The FontName attribute is set to Serif in the axis node. This value is then inherited by all of its ancestor nodes.

The TextColor attribute is set differently in the x-axis and y-axis nodes. Note that this setting is inherited by both the AxisTitle and nodes within the same axis.

The y-axis title node has its FontSize attribute set to 20, so it is larger. Also, its TextAngle attribute is set to -90. By default, the y-axis title is drawn at a 90 degree angle, so the -90 degree setting flips the title from its usual position.

(Download Code)

 

using Imsl.Chart2D;

using System.Drawing;

 

public class SampleAxisTitleFormatted : FrameChart {

 

    public SampleAxisTitleFormatted() {

        Chart chart = this.Chart;

        AxisXY axis = new AxisXY(chart);

        double[] y = {4, 2, 3, 9};

        Data data = new Data(axis, y);

 

        axis.FontName = "Serif";

 

        axis.AxisX.TextColor = Color.Blue;

        axis.AxisX.AxisTitle.SetTitle("The X Axis");

 

        axis.AxisY.TextColor = Color.DarkGray;

        axis.AxisY.AxisTitle.SetTitle("The Y Axis");

        axis.AxisY.AxisTitle.TextAngle = -90;

        axis.AxisY.AxisTitle.FontSize = 20;

    }

 

    public static void Main(string[] argv) {

        System.Windows.Forms.Application.Run(

            new SampleAxisTitleFormatted());

    }

}

 



Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260