APLX Help : System Classes : The Chart and Series Objects : Axes, Coordinates and Scales
|
|
![]() |
Axes, Coordinates and Scales |
Apart from Pie charts, all the different chart types plot a dependent variable (known as Y) against another variable (known as X). By convention, the X axis is along the horizontal, and the Y axis is along the vertical, except for Horizontal Bar and Stacked Horizontal Bar charts, where the two are reversed. By default, the Chart Object will select the scale of the chart (i.e. the range from the minimum X and Y coordinates to the maximum X and Y coordinates) automatically. It will also automatically choose where to place tick marks and labels along the axes. There are two types of tick mark; major tick marks (which are by default labelled), and minor tick marks (which are not labelled). The major tick marks are slightly longer. The Chart object chooses the intervals between tick marks to give a reasonable number of ticks depending on the size of the chart, and will place the marks at intervals which mean that the labels are round numbers (multiples of 1, 2, 5 or 10 times integral powers of ten). The Chart object will also choose the intercepts, i.e. the point
where the axes cross each other. This will usually be 0 if 0 is
within the scale, else the lowest X or Y point on the scale. This
means that the Y axis is usually shown on the left of the chart, but
you can change this by using an alternate Y scale (see below), and
you can also cause the Y axis to be drawn on both sides of the chart
using the For Bar and Stacked Bar charts (and the Horizontal versions of these), the bars are by default drawn centred on integers 1, 2, 3.. etc. The Alternate ScaleAs well as the main Y scale, you can also specify that an alternate Y
scale is used for one or more of the series on the chart, by setting
the ∇Chart_ObesityTobacco;⎕IO;obesity;tobacco;Health [1] ⍝ Sample line chart with two different scales [2] Health←'⎕' ⎕NEW 'Window' ⋄ Health.scale←5 ⋄ Health.size←450 600 [3] Health.title←'Sample: Obesity and Tobacco' [4] Health.Chart.New 'Chart' ⋄ Health.Chart.align←¯1 [5] Health.Chart.type←'line' ⋄ Health.Chart.style←1 [6] Health.Chart.title←'Tobacco Consumption and Obesity' [7] Health.Chart.subtitle←'United Kingdom' [8] ⎕IO←0 [9] ⍝ Set up the data [10] obesity←1980 7 1991 14 1992 14 1993 15 1994 16 1995 16 1996 17 [11] obesity←13 2⍴obesity,1997 18 1998 19 1999 20 2000 21 2001 22 2002 22 [12] tobacco←1960 51.5 1970 49.5 1980 39 1990 30 1992 28 [13] tobacco←10 2⍴tobacco,1994 27 1996 28 1998 27 2000 27 2001 27 [14] Health.Chart.s1.New 'series' [15] Health.Chart.s1.marker←'⋄' ⋄ Health.Chart.s1.fillmarker←1 [16] Health.Chart.s1.caption←'Tobacco consumption (left axis)' [17] Health.Chart.s1.values←tobacco [18] Health.Chart.s2.New 'series' [19] Health.Chart.s2.marker←'⋄' ⋄ Health.Chart.s2.fillmarker←1 [20] Health.Chart.s2.caption←'Obesity (right axis)' [21] Health.Chart.s2.usealtscale 1 [22] Health.Chart.s2.values←obesity [23] Health.Chart.yaxislabel←'% of population daily smokers' [24] Health.Chart.yaltaxislabel←'% of population with BMI>30 kg/m2' [25] Health.Chart.xmajorticks←1960 1970 1980 1990 2000 [26] ⍝ [27] ⍝ Wait until window is closed [28] 0 0⍴⎕WE Health ∇ Line [15] of this function causes the second series to be drawn using the alternate scale, which is unrelated to the main Y axis scale. The effect is as follows:
Specifying your own tick positions and interceptsIf you wish, you can choose your own positions for the tick marks along
any of the axes. You specify the values where major tick marks
should be drawn by writing a vector of values to the Chart properties
If you specify your own tick positions, the final scale chosen will normally be from the lowest tick mark you specify to the highest. However, the scale will be extended if any of the points in any enabled Series is outside this range, so that the scale can represent all points on all the series. In addition, you can change where the axes cross by specifying the
Specifying your own tick labelsBy default, the Chart object writes a label next to each major tick
mark, showing the numeric value of the point on the axis. If you
wish, you can specify your own labels using the properties There are two special cases. For Bar charts (including the stacked and
horizontal variants), there is no need to specify the X tick
positions, since the bars are always drawn at 1, 2, 3... For Pie
charts, there are no tick positions as such, but the Specifying axis labelsThe Logarithmic ScalesSometimes the range of data contained in a series is so large that a
logarithmic scale is more appropriate. You can cause a logarithmic
scale to be used for an axis by setting one of the MS.Chart.ylogscale←1 Note that, in this example, the minor ticks represent 2, 3, .. 9 times the power of ten shown at the previous major tick. |
|
APLX Help : System Classes : The Chart and Series Objects : Axes, Coordinates and Scales
|
Copyright © 1996-2010 MicroAPL Ltd