Chart::GGPlot::Limits - Functions for applying limits to the scales
version 0.002003
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);
The module provides some functions for specifying limits of a plot. By default, any values outside limits will be not plottted.
lims(%pairs)
Call limits() on each kv pair in %pairs. Returns an array ref like [ limits($key1, $value1), ... ].
limits()
%pairs
[ limits($key1, $value1), ... ]
xlim($a, $b)
This is a shortcut of
limits(x => [$a, $b]);
ylim($a, $b)
limits(y => [$a, $b]);
limits($var, $lims)
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]);
Stephan Loyd <sloyd@cpan.org>
This software is copyright (c) 2019-2023 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.
To install Chart::GGPlot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Chart::GGPlot
CPAN shell
perl -MCPAN -e shell install Chart::GGPlot
For more information on module installation, please visit the detailed CPAN module installation guide.