Axes
Elements involved in creating plot axes include the classes ContinuousAxis
(which draws the axis line and arrow), ContinuousAxisTicks
(which draws the tick marks), ContinuousAxisLabels
(which draws the labels), ContinuousAxisTitle
(which draws the title), and Grid
(which draws a grid).
The following example shows how to use these elements:
Expand source code
The ContinuousAxis
class
A ContinuousAxis
draws the axis line and its arrow. An instance of this class can be created using the constructor, which requires a startPoint
, endPoint
, and coordinateSystem
. The startPoint
and endPoint
should be expressed in data space coordinates, and the coordinateSystem
is used to convert these to plot space.
The ContinuousAxisTicks
class
This plot elements draws the ticks on an axis. The constructor for this class is the same as for the ContinuousAxis
class; by default, 11 ticks (determining 10 intervals) are drawn on the axis. For example, if the axis goes from (0, 0)
to (10, 0)
in data coordinates, ticks will be drawn at (0, 0)
, (1, 0)
, …, (10, 0)
. You can change this by changing the value of the IntervalCount
property, and you can change the size of the ticks with the SizeAbove
and SizeBelow
properties. These should be set to a function delegate taking as a parameter the tick index and returning the size of the tick in plot coordinates.
Note that the ticks are necessarily drawn at equally-spaced intervals. If you wish to draw ticks at specific positions, you should instead use something like a ScatterPoints
plot element, where you can specify the position at which to draw the symbol and the symbol you want to draw.
The ContinuousAxisLabels
class
This plot elements draws the labels on an axis. The constructor for this class is the same as for the ContinuousAxis
class; by default, 11 labels (determining 10 intervals) are drawn on the axis. For example, if the axis goes from (0, 0)
to (10, 0)
in data coordinates, labels will be drawn at (0, 0)
, (1, 0)
, …, (10, 0)
. You can change this by changing the value of the IntervalCount
property. Other properties of this class can be used to determine the position, orientation and text of the labels.
Note that the labels are necessarily drawn at equally-spaced intervals. If you wish to draw ticks at specific positions, you should instead use something like a DataLabels
plot element, where you can specify the position at which to draw the labels.
The ContinuousAxisTitle
class
This plot element draws a title for an axis. The constructor for this class requires the title to draw (either as a string
or as an IEnumerable<FormattedText>
), the starting and ending points for the axis, the coordinate system and (if the title was provided as a string
) the presentation attributes.
Note that if you provide the title as an IEnumerable<FormattedText>
, the font properties of the presentation attributes will not be used when drawing the title (the information within the FormattedText
objects will be used instead). Furthermore, even when providing the title as a string
, the font from the presentation attributes is only used in the constructor when creating the object. This means that if you change the element’s PresentationAttributes
later on, only things like the colour of the title will change, but not the font or the font size; if you wish to change the font or font size, you will need to change the value of the IEnumerable<FormattedText> title
property.
The Grid
class
This plot element draws a grid. This is specified by providing four points (and a coordinate system) to the constructor for this class; the four points identify two “sides”, and grid lines are drawn from equally spaced points on the first side to the corresponding equally spaced points on the second side. Note that the two sides do not necessarily need to be parallel or have the same length.