NAME

Chart::GGPlot::Limits - Functions for applying limits to the scales

VERSION

version 0.0009

SYNOPSIS

use Chart::GGPlot qw(:all);

my $plot1 = ggplot(data => $mtcars, 
                   mapping => aes(x => 'mpg', y => 'wt')) + 
                geom_point() + xlim(15, 20);

# if the larger value comes first, the scale will be reversed
my $plot2 = ggplot(data => $mtcars, 
                   mapping => aes('mpg', 'wt')) + 
                geom_point() + xlim(20, 15);

# you can leave one value as NA to compute from the range of the data
my $plot3 = ggplot(data => $mtcars,
                   mapping => aes('mpg', 'wt')) + 
                geom_point() + xlim(NA, 20);

DESCRIPTION

The module provides some functions for specifying limits of a plot. By default, any values outside limits will be not plottted.

FUNCTIONS

lims

lims(%pairs)

Call limits() on each kv pair in %pairs. Returns an array ref like [ limits($key1, $value1), ... ].

xlim

xlim($a, $b)

This is a shortcut of

limits(x => [$a, $b]);

ylim

ylim($a, $b)

This is a shortcut of

limits(y => [$a, $b]);

limits

limits($var, $lims)

expand_limits

expand_limits(%params)

Expand the plot limits, using data.

my $p = ggplot($mtcars, aes( x=> 'mpg', y => 'wt')) + geom_point();
$p->expand_limits(x => 0);
$p->expand_limits(y => [1, 9]);

AUTHOR

Stephan Loyd <sloyd@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by Stephan Loyd.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.