Node:area, Next:, Previous:chart_data, Up:Top



Area

Class area.T defines the location and size of a chart. It also defines the coordinate system (linear, log, or enumeration) of the X and Y axes.

The X (or Y) coordinate system is defined by attribute x_coord_system (or y_coord_system), which takes an object of type coord.T. Class coord.T defines how a X (or a Y) value will be mapped to a display (canvas) location. PyChart provides three standard coordinate systems: linear_coord.T (for linear mapping; this is the default), log_coord.T (for logarithmic mapping), and category_coord.T (enumeration of values). Most charts will do ok by instantiating one of these pre-defined coordinate classes, but you can also define your own wacky coordinate system. See coord.

For log and linear coordinate systems, the minimum and maximum displayable values in the area are computed automatically from the plots unless they are defined explicitly via attribute x_range. See the below example:

ar = area.T(x_coord_system = log_coord.T(), x_range = (10, None), ...)

Here, an X axis is drawn with a logarithmic scale. The minimum value will be 10, and the maximum value will be computed from the values given to plots. The below is an example of a category coordinate system.

samples = [("apple", 10), ("orange", 30), ("blueberry", 20)],
ar = area.T(x_coord_system = category_coord(samples, 0))
ar.add_plot(bar_plot.T(data = samples))

We now list the attributes understood by an area.T object.

bg_style type: fill_style.T Attribute
Default: None. Background fill-pattern. See fill_style.

border_line_style type: line_style.T Attribute
Default: None. Line style of the outer frame of the chart. See line_style.

legend type: legend.T Attribute
Default: a legend is by default displayed in the right-center of the chart.. The legend of the chart. See legend.

loc type: (x,y) Attribute
Default: (0, 0). The location of the bottom-left corner of the chart.

size type: (x,y) Attribute
Default: (120, 110). The size of the chart-drawing area, excluding axis labels, legends, tick marks, etc.

x_axis type: axis.X Attribute
Default: None. The X axis. See axis..

x_axis2 type: axis.X Attribute
Default: None. The second X axis. This axis should be non-None either when you want to display plots with two distinct domains or when you just want to display two axes at the top and bottom of the chart. See axis..

x_coord type: coord.T Attribute
Default: A linear coordinate system.. Set the X coordinate system. See coord.. See coord.

x_grid_interval type: Number or function Attribute
Default: None. The horizontal grid-line interval. A numeric value specifies the interval at which lines are drawn. If value is a function, it takes two arguments, (MIN, MAX), that tells the minimum and maximum values found in the sample data. The function should return a list of values at which lines are drawn.

x_grid_over_plot type: int Attribute
Default: 0. If true, grid lines are drawn over plots. Otherwise, plots are drawn over grid lines.

x_grid_style type: line_style.T Attribute
Default: None. The style of horizontal grid lines. See line_style.

x_range type: (x,y) Attribute
Default: None. Specifies the range of X values that are displayed in the chart. IF the value is None, both the values are computed automatically from the samples. Otherwise, the value must be a tuple of format (MIN, MAX). MIN and MAX must be either None or a number. If None, the value is computed automatically from the samples. For example, if x_range = (None,5), then the minimum X value is computed automatically, but the maximum X value is fixed at 5.

y_axis type: axis.Y Attribute
Default: None. The Y axis. See axis..

y_axis2 type: axis.Y Attribute
Default: None. The second Y axis. This axis should be non-None either when you want to display plots with two distinct ranges or when you just want to display two axes at the left and right of the chart. See axis..

y_coord type: coord.T Attribute
Default: A linear coordinate system.. Set the Y coordinate system. See coord.. See coord.

y_grid_interval type: Number or function Attribute
Default: None. The vertical grid-line interval. See also x_grid_interval

y_grid_over_plot type: int Attribute
Default: 0. See x_grid_over_plot.

y_grid_style type: line_style.T Attribute
Default: line_style.gray70_dash3. The style of vertical grid lines. See line_style.

y_range type: (x,y) Attribute
Default: None. Specifies the range of Y values that are displayed in the chart. IF the value is None, both the values are computed automatically from the samples. Otherwise, the value must be a tuple of format (MIN, MAX). MIN and MAX must be either None or a number. If None, the value is computed automatically from the samples. For example, if y_range = (None,5), then the minimum Y value is computed automatically, but the maximum Y value is fixed at 5.

Objects of area.T also support several methods:

area.T:add_plot PLOT, ... Method
Add plots. plot must be a plot. See line_plot, bar_plot, pie_plot, range_plot.

area.T:draw CANVAS = None Method
Draw plots, axes, and the legend. This procedure must be called at the end of every PyChart application. CANVAS is an optional parameter that specifies the output. See Drawing on canvas.

area.T:x_pos XVAL Method
Converts X XVAL to a coordinate on the canvas (see canvas). See Unit.

area.T:y_pos YVAL Method
Converts Y YVAL to a coordinate on the canvas (see canvas). See Unit.