GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Imager::Plot::Axis(3) User Contributed Perl Documentation Imager::Plot::Axis(3)

Imager::Plot::Axis - Axis handling of Imager::Plot.

  use Imager;
  use Imager::Plot::Axis;

  # Create our dummy data
  @X = 0..10;
  @Y = map { $_**3 } @X;

  # Create Axis object

  $Axis = Imager::Plot::Axis->new(Width => 200, Height => 180, GlobalFont=>"ImUgly.ttf");
  $Axis->AddDataSet(X => \@X, Y => \@Y);

  $Axis->{XgridShow} = 1;  # Xgrid enabled
  $Axis->{YgridShow} = 0;  # Ygrid disabled

  $Axis->{Border} = "lrb"; # left right and bottom edges

  # See Imager::Color manpage for color specification
  $Axis->{BackGround} = "#cccccc";

  # Override the default function that chooses the x range
  # of the graph, similar exists for y range

  $Axis->{make_xrange} = sub {
      $self = shift;
      my $min = $self->{XDRANGE}->[0]-1;
      my $max = $self->{XDRANGE}->[1]+1;
      $self->{XRANGE} = [$min, $max];
  };

  $img = Imager->new(xsize=>600, ysize => 400);
  $img->box(filled=>1, color=>"white");

  $Axis->Render(Xoff=>50, Yoff=>370, Image=>$img);

  $img->write(file=>"foo.ppm") or die $img->errstr;

This part of Imager::Plot takes care of managing the graph area itself. It handles the grid, tickmarks, background in axis area and the data sets of course. All the data sets have to be given to the Axis object before rendering it so that everything is only written only once and scaling of axis can be done automatically. This also helps in doing chartjunk tricks like shadows.

The size of the Axis area is controlled by the Width and Height parameters of the "new" method. The border region/frame of the axis is considered to lie in the coordinate system. The default order of drawing is the following: Background image, grid, frame, ticks.

Note that the Axis currently renders the ticklabels. This might change in the near future.

Arnar M. Hrafnkelsson, addi@umich.edu

2002-08-05 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.