Chart-GGPlot
view release on metacpan or search on metacpan
lib/Chart/GGPlot/Geom/Boxplot.pm view on Meta::CPAN
use Chart::GGPlot::Position::Functions qw(position_dodge2);
use Chart::GGPlot::Util qw(:all);
use Chart::GGPlot::Util::Pod qw(layer_func_pod);
has '+default_aes' => (
default => sub {
Chart::GGPlot::Aes->new(
weight => pdl(1),
color => PDL::SV->new( ['grey20'] ),
fill => PDL::SV->new( ['white'] ),
size => pdl(0.5),
alpha => NA(),
shape => pdl(19),
linetype => PDL::SV->new( ['solid'] ),
);
}
);
classmethod required_aes() { [qw(x lower upper middle ymin ymax)] }
classmethod extra_params () {
[
qw(
fatten
outlier_color outlier_fill outlier_shape outlier_size
outlier_stroke outlier_alpha
notch notchwidth varwidth na_rm width
)
]
}
my $geom_boxplot_pod = layer_func_pod(<<'EOT');
geom_boxplot(:$mapping=undef, :$data=undef,
:$stat='boxplot', :$position='dodge2',
:$outlier_color=undef, :$outlier_colour=undef,
:$outlier_fill=undef, :$outlier_shape=undef,
:$outlier_size=1.5, :$outlier_stroke=undef,
:$outlier_alpha=undef,
:$notch=false, :$notchwidth=0.25,
:$varwidth=false, :$na_rm=false,
:$show_legend=undef, :$inherit_aes=true,
%rest)
The boxplot compactly displays the distribution of a continuous
variable. It visualises five summary statistics (the median, two hinges
and two whiskers), and all "outlying" points individually.
Arguments:
=over 4
%TMPL_COMMON_ARGS%
=item * $outlier_color, $outlier_fill, $outlier_size, $outlier_stroke,
$outlier_alpha
Default aesthetics for outliers. Set to C<undef> to inherit from the
aesthetics used for the box.
Sometimes it can be useful to hide the outliers, for example when
overlaying the raw data points on top of the boxplot. Hiding the
outliers can be achieved by setting C<outlier_shape =E<gt> ''>.
Importantly, this does not remove the outliers, it only hides them, so
the range calculated for the y-axis will be the same with outliers
shown and outliers hidden.
=item * $notch
If false (default) make a standard box plot. If true, make a notched
box plot. Notches are used to compare groups; if the notches of two
boxes do not overlap, this suggests that the medians are significantly
different.
=item * $notchwidth
For a notched box plot, width of the notch relative to the body.
=back
See also L<Chart::GGPlot::Stat::Functions/stat_boxplot>.
EOT
my $geom_boxplot_code = fun (
:$data=undef, :$mapping=undef,
:$stat='boxplot', :$position='dodge2',
:$outlier_color=undef, :$outlier_colour=undef,
:$outlier_fill=undef, :$outlier_shape=undef,
:$outlier_size=1.5, :$outlier_stroke=undef,
:$outlier_alpha=undef,
:$notch=false, :$notchwidth=0.25,
:$varwidth=false, :$na_rm=false,
:$show_legend=undef, :$inherit_aes=true,
%rest )
{
if ( not Ref::Util::is_ref($position) ) {
if ($varwidth) {
$position = position_dodge2( preserve => 'single' );
}
}
else {
if ( $position->preserve eq 'total' and $varwidth ) {
warn "Can't preserve total widths when varwidth is true.";
$position->preserve('single');
}
}
return Chart::GGPlot::Layer->new(
data => $data,
mapping => $mapping,
stat => $stat,
geom => 'boxplot',
position => $position,
show_legend => $show_legend,
inherit_aes => $inherit_aes,
params => {
outlier_color => ( $outlier_color // $outlier_colour ),
outlier_fill => $outlier_fill,
outlier_shape => $outlier_shape,
outlier_size => $outlier_size,
outlier_stroke => $outlier_stroke,
( run in 4.278 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )