Chart-GGPlot

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  - New feature: geom_col().
  - Add JSON::XS to runtime requires.
 
0.0005      2019-06-09
  - New feature: experimental support of geom_smooth(). At present loess
    (locally weighted estimated scatterplot smoothing) and simple linear
    regression are supported.
  - New feature: experimental support of geom_polygon().
  - New feature: experimental support for geom_rect(), geom_tile(), and
    geom_raster().
  - New feature: Layer's show_legend attribute now really has effect.
  - Bug fix: Fixed alpha handling in the plotly backend.
  - Bug fix: Now Chart::GGPlot::Stat would not die when generate data for
    data with more points for stat then for raw data.
  - Bug fix: Fixed Chart::GGPlot::Util::match() for cases where its second
    argument has BAD values.
  - Make sure Chart::GGPlot::Util::seq_n() return piddle's last element
    always be same as its $to argument.
  - Plotly backend: legend title now aligns left and supports newlines in
    legend title text.
  - Plotly backend: now hovertext is shown for scattergl plots.
 
0.0003      2019-05-04
  - New feature: basic support of geom_boxplot()
  - New feature: coord_flip()
  - coord_cartesian() now really supports :$xlim, :$ylim arguments.
  - Add a Chart::GGPlot::Plot::iplot() method for convenience of plotting
    in Jupyter Notebook.
  - Chart::GGPlot::Util::dollar() behavior is now more consistant. Hope
    this can fix a unit test failure in some special environments.

examples/geom_point_01_05.pl  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env perl
 
# Do not show legend.
 
use 5.016;
 
use Chart::GGPlot qw(:all);
use Data::Frame::Examples qw(mtcars);
 
my $save_as;
GetOptions( 'o=s' => \$save_as );
 
my $mtcars = mtcars();
 
my $p = ggplot(
    data    => $mtcars,
    mapping => aes( x => 'wt', y => 'mpg' )
)->geom_point(
    mapping     => aes( color => 'factor($cyl)' ),
    show_legend => 0
);
 
if (defined $save_as) {
    $p->save($save_as);
} else {
    $p->show();
}

examples/geom_polygon_01_02.pl  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env perl
 
# Do not show legend.
 
use 5.016;
 
use Chart::GGPlot qw(:all);
use PDL::Core qw(pdl);
 
my $save_as;
GetOptions( 'o=s' => \$save_as );

examples/geom_polygon_01_02.pl  view on Meta::CPAN

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
            1,    1.5, 2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2
        ),
    ]
);
 
my $p = ggplot(
    data    => $datapoly,
    mapping => aes( x => 'x', y => 'y' )
)->geom_polygon(
    mapping     => aes( fill => 'value', group => 'id' ),
    show_legend => 0
);
 
if ( defined $save_as ) {
    $p->save($save_as);
}
else {
    $p->show();
}

lib/Chart/GGPlot/Backend/Plotly.pm  view on Meta::CPAN

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
my %discrete_scales = map {
    my $scale = $_;
    if ( $scale->isa('Chart::GGPlot::Scale::Discrete') ) {
        map { $_ => $scale } @{ $scale->aesthetics };
    }
    else {
        ();
    }
} @{ $plot->scales->non_position_scales->scales };
 
# variables that produce multiple traces and deserve their own legend entries
my @split_legend = map { "${_}_raw" } ( sort keys %discrete_scales );
$log->debugf( "Variables that would cause legend be splitted : %s",
    Dumper( \@split_legend ) )
  if $log->is_debug;
 
my $split_by =
  [ uniq( @split_legend, @{ $self->_split_on( $class_geom_impl, $data ) } )
  ];
 
my $split_vars = $split_by->intersect($data->names);
 
my $hover_text_aes;     # which aes shall be displayed in hover text?
{
    # While $plot->labels also looks like containing what we need,
    # actually it be cleared or set to other values, so it can't
    # really be used for generating the hovertext. Here we would
    # get the aes from $layer->mapping and $layer->stat.

lib/Chart/GGPlot/Backend/Plotly.pm  view on Meta::CPAN

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
        };
 
        my $splitted = $d->split($fac);
        @splitted_sorted =
          map { $splitted->{$_} } sort { $a cmp $b } keys %$splitted;
    }
    else {
        push @splitted_sorted, $d;
    }
 
    my $showlegend = @split_legend->intersect( $data->names )->length > 0;
    return @splitted_sorted->map(
        sub {
            my ($d) = @_;
 
            my $traces = $class_geom_impl->to_traces($d, $params, $plot);
            for my $trace (@$traces) {
                my $legend_key = join(
                    ', ',
                    map {
                        if ( $d->exists($_) ) {
                            my $col_data = $d->at($_);
                            $col_data->slice(pdl(0))->as_pdlsv->at(0);
                        }
                        else {
                            ();
                        }
                    } @split_legend
                );
                $trace->name($legend_key);
 
                # some types like heatmap may not have below methods
                if ( $trace->can('showlegend') ) {
                    $trace->legendgroup($legend_key);
                    $trace->showlegend($showlegend);
                }
            }
            return @$traces;
        }
    );
};
 
my $splitted_data = $data->split( $data->at('PANEL') );
my $splitted_prestats_data =
  $prestats_data->split( $prestats_data->at('PANEL') );

lib/Chart/GGPlot/Backend/Plotly.pm  view on Meta::CPAN

208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
    my $marker = Chart::Plotly::Trace::Scatter::Marker->new(
        color      => [ 0, 1 ],
        colorscale => \@colorscale,
        colorbar   => Chart::Plotly::Trace::Scatter::Marker::Colorbar->new(
            title =>
              Chart::Plotly::Trace::Scatter::Marker::Colorbar::Title->new(
                text => $guide->title,
                side => 'top'
              ),
            # R's default is 1.2 "lines" for "legend.key.size".
            # We don't support the grid unit system now (maybe in future
            # we can develop it on Graphics::Grid::Unit), now we just
            # leave it be for plotly to use its default.
            #thickness => 30,
            tickmode => 'array',
            ticktext => $ticktext,
            tickvals => $tickvals,
            ticklen  => 2,
            len      => 0.5,
        ),
    );
 
    return Chart::Plotly::Trace::Scatter->new(
        x          => [0],
        y          => [0],
        type       => 'scatter',
        mode       => 'markers',
        opacity    => 0,
        hoverinfo  => 'none',
        showlegend => 0,
        marker     => $marker,
    );
}
 
method _to_plotly ($plot_built) {
    my $plot   = $plot_built->plot;
    my $layers = $plot->layers;
    my $layout = $plot_built->layout;
 
    my $plotly = Chart::Plotly::Plot->new();

lib/Chart/GGPlot/Backend/Plotly.pm  view on Meta::CPAN

411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
} # for (qw(x y))
 
# guides
my $gdefs = $plot->guides->build(
    $plot->scales,
    labels          => $plot->labels,
    layers          => $layers,
    default_mapping => $plot->mapping
);
 
# if $gdefs is empty, then no legend is displayed.
my $global_showlegend = !!@$gdefs;
 
my %seen_legendgroup;
for my $i ( 0 .. $#$layers ) {
    my $layer = $layers->[$i];
    my $data  = $plot_built->layer_data($i);
    my $prestats_data  = $plot_built->layer_prestats_data($i);
 
    $log->debug( "data at layer $i:\n" . $data->string ) if $log->is_debug;
 
    my $traces =
      $self->layer_to_traces( $layer, $data, $prestats_data,
        $layout, $plot );
 
    for my $panel (@$traces) {
        for my $trace (@$panel) {
            if ( $trace->can('showlegend') ) {
                if ( not $global_showlegend ) {
                    $trace->showlegend(0);
                }
                elsif ( $seen_legendgroup{ $trace->legendgroup }++ ) {
 
                    # for traces of same legend group, show legend for
                    # only the first one of them.
                    $trace->showlegend(0);
                }
            }
 
            $plotly->add_trace($trace);
        }
 
        if ( List::AllUtils::any { $_->$_call_if_can('showlegend') }
            @$panel )
        {
            $plotly_layout{showlegend} = JSON::true;
 
            # legend title
            #
            # TODO: See if plotly will officially support legend title
            my $br = br();
            my $legend_titles =
              join( $br, map { $_->title =~ s/\n/$br/gr; } @$gdefs );
 
            my $annotations = $plotly_layout{annotations} //= [];
            push @$annotations,
              {
                x         => 1.02,
                y         => 1,
                align     => 'left',
                xanchor   => 'left',
                yanchor   => 'bottom',
                text      => $legend_titles,
                showarrow => JSON::false,
                xref      => 'paper',
                yref      => 'paper',
              };
 
            # Default right margin is too small for legend title.
            #
            # TODO: How to automatically calc the margin?
            #  May need to use libraries like Cairo for text width?
            #  Best if plotly can natively support legend title.
            $plotly_layout{margin} = { r => 150 };
        }
    }
}
 
# Above operations already ensures for each legend group there be only
#  one legend item. So there is no need to keep legendgroup gap, then
#  it looks better to me compared with having the default gap.
$plotly_layout{legend} = { tracegroupgap => 0 };
 
$plotly_layout{hovermode} = 'closest';
$plotly_layout{barmode} = $barmode // 'relative';
 
# border
my $el_panel_border = $theme->at('panel_border');
unless ( not defined $el_panel_border or $el_panel_border->is_blank ) {
    $plotly_layout{shapes} = [
        {
            type      => 'rect',

lib/Chart/GGPlot/Backend/Plotly.pm  view on Meta::CPAN

510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
            xref => 'paper',
            x0   => 0,
            x1   => 1,
            yref => 'paper',
            y0   => 0,
            y1   => 1,
        }
    ];
}
 
if ( $theme->at('legend_position') eq 'none' ) {
    $plotly_layout{showlegend} = JSON::false;
}
 
# colorbar
my ($colorbar) =
  grep { $_->$_DOES('Chart::GGPlot::Guide::Colorbar') } @$gdefs;
if ($colorbar) {
    my $colorbar_trace = $self->_colorbar_to_trace($colorbar);
    $plotly->add_trace($colorbar_trace);
}

lib/Chart/GGPlot/Geom.pm  view on Meta::CPAN

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  Chart::GGPlot::HasDefaultAes
  Chart::GGPlot::HasNonMissingAes
  Chart::GGPlot::HasParams
  Chart::GGPlot::HasCollectibleFunctions
);
 
classmethod optional_aes() { [] }
 
method setup_data ($data, $params) { $data }
 
# Renders a single legend key.
sub draw_key { return draw_key_point(@_) }
 
method handle_na ( $data, $params ) {
    return remove_missing(
        $data,
        na_rm => $params->at('na_rm'),
        vars  => [ @{ $self->required_aes }, @{ $self->non_missing_aes } ],
        name  => $self->name
    );
}

lib/Chart/GGPlot/Geom/Bar.pm  view on Meta::CPAN

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
has '+non_missing_aes' => ( default => sub { [qw(xmin xmax ymin ymax)] } );
 
classmethod required_aes() { [qw(x y)] }
classmethod extra_params() { [qw(na_rm width)] }
 
my $geom_bar_pod = layer_func_pod(<<'EOT');
 
        geom_bar(:$mapping=undef, :$data=undef, :$stat='count',
                 :$position='stack', :$width=undef,
                 :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                 %rest)
 
    The "bar" geom makes the height bar proportional to the number of cases
    in each group (or if the C<weight> aesthetic is supplied, the sum of the
    C<weights>).
    It uses C<stat_count()> by default: it counts the number of cases at
    each x position.
 
    Arguments:

lib/Chart/GGPlot/Geom/Bar.pm  view on Meta::CPAN

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    =back
 
    See also L<Chart::GGPlot::Stat::Functions/stat_count>.
 
EOT
 
my $geom_bar_code = fun (
        :$mapping = undef, :$data = undef,
        :$stat = 'count', :$position = 'stack',
        :$width = undef, :$na_rm = false,
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        geom        => 'bar',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            width => $width,
            na_rm => $na_rm,
            %rest,
        },
    );
};
 
my $geom_histogram_pod = layer_func_pod(<<'EOT');
 
        geom_histogram(:$mapping=undef, :$data=undef, :$stat="bin",
                       :$position="stack", :$binwidth=undef, :$bins=undef,
                       :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                       %rest)
 
    Visualise the distribution of a single continuous variable by dividing
    the x axis into bins and counting the number of observations in each
    bin. This "histogram" geom displays the counts with bars.
 
    =over 4
 
    %TMPL_COMMON_ARGS%

lib/Chart/GGPlot/Geom/Bar.pm  view on Meta::CPAN

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
    See also L<Chart::GGPlot::Stat::Functions/stat_bin>.
 
EOT
 
my $geom_histogram_code = fun (
        :$data = undef, :$mapping = undef,
        :$stat = "bin", :$position = "stack",
        :$binwidth = undef, :$bins = undef,
        :$na_rm = false,
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        geom        => 'bar',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            binwidth => $binwidth,
            bins     => $bins,
            na_rm    => $na_rm,
            pad      => false,
            %rest
        },
    ); 
};
 
my $geom_col_pod = layer_func_pod(<<'EOT');
 
        geom_col(:$mapping=undef, :$data=undef, :$position="stack",
                 :$width=undef, :$na_rm=false, :$show_legend=undef,
                 :$inherit_aes=true,
                 %rest)
 
    Bar plot. Different from geom_bar(), geom_col() uses stat_identity():
    it leaves the data as is.
 
    =over 4
 
    %TMPL_COMMON_ARGS%

lib/Chart/GGPlot/Geom/Bar.pm  view on Meta::CPAN

151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    Bar width. By default, set to 90% of the resolution of the data.
 
    =back
 
EOT
 
my $geom_col_code = fun (
        :$data = undef, :$mapping = undef, :$position = "stack",
        :$width = undef,
        :$na_rm = false, :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => 'identity',
        geom        => 'bar',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            width => $width,
            na_rm => $na_rm,
            %rest,
        },
    ); 
};
 
classmethod ggplot_functions() {

lib/Chart/GGPlot/Geom/Blank.pm  view on Meta::CPAN

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
our $VERSION = '0.002003'; # VERSION
 
with qw(https://metacpan.org/pod/Chart::GGPlot::Geom">Chart::GGPlot::Geom);
 
 
my $geom_blank_pod = '';
my $geom_blank_code = fun (
        :$mapping = undef, :$data = undef,
        :$stat = "identity", :$position = "identity",
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        check_aes   => false,
        geom        => 'blank',
        params      => \%rest,
    );
};
 
classmethod ggplot_functions() {
    return [
        {

lib/Chart/GGPlot/Geom/Boxplot.pm  view on Meta::CPAN

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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

lib/Chart/GGPlot/Geom/Boxplot.pm  view on Meta::CPAN

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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,
            outlier_alpha  => $outlier_alpha,
            notch          => $notch,
            notchwidth     => $notchwidth,

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
L<Chart::GGPlot::Plot> methods, to add layers into the plot object.
 
=head1 FUNCTIONS
 
=head2 geom_blank
 
=head2 geom_bar
 
    geom_bar(:$mapping=undef, :$data=undef, :$stat='count',
             :$position='stack', :$width=undef,
             :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
             %rest)
 
The "bar" geom makes the height bar proportional to the number of cases
in each group (or if the C<weight> aesthetic is supplied, the sum of the
C<weights>).
It uses C<stat_count()> by default: it counts the number of cases at
each x position.
 
Arguments:

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Bar width. By default, set to 90% of the resolution of the data.
 
=back
 
See also L<Chart::GGPlot::Stat::Functions/stat_count>.
 
=head2 geom_histogram
 
    geom_histogram(:$mapping=undef, :$data=undef, :$stat="bin",
                   :$position="stack", :$binwidth=undef, :$bins=undef,
                   :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                   %rest)
 
Visualise the distribution of a single continuous variable by dividing
the x axis into bins and counting the number of observations in each
bin. This "histogram" geom displays the counts with bars.
 
=over 4
 
=item * $mapping

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
You should always override this C<$bins> or C<$binwidth>, exploring
multiple widths to find the best to illustrate the stories in your data.
 
=back
 
See also L<Chart::GGPlot::Stat::Functions/stat_bin>.
 
=head2 geom_col
 
    geom_col(:$mapping=undef, :$data=undef, :$position="stack",
             :$width=undef, :$na_rm=false, :$show_legend=undef,
             :$inherit_aes=true,
             %rest)
 
Bar plot. Different from geom_bar(), geom_col() uses stat_identity():
it leaves the data as is.
 
=over 4
 
=item * $mapping

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
=head2 geom_boxplot
 
    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

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
For a notched box plot, width of the notch relative to the body.
 
=back
 
See also L<Chart::GGPlot::Stat::Functions/stat_boxplot>.
 
=head2 geom_path
 
    geom_path(:$mapping=undef, :$data=undef, :$stat='identity',
              :$position='identity', :$na_rm=false, :$show_legend=undef,
              :$inherit_aes=true,
              %rest)
 
The "path" geom connects the observations in the order in which they
appear in the data.
 
=over 4
 
=item * $mapping

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
These are often aesthetics, used to set an aesthetic to a fixed value,
like C<color =E<gt> "red", size =E<gt> 3>.
They may also be parameters to the paired geom/stat.
 
=back
 
=head2 geom_point
 
    geom_point(:$mapping=undef, :$data=undef, :$stat='identity',
               :$position='identity',
               :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
               %rest)
 
The "point" geom is used to create scatterplots.
The scatterplot is most useful for displaying the relationship between
two continuous variables.
A bubblechart is a scatterplot with a third variable mapped to the size
of points.
 
Arguments:

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
Other arguments passed to C<Chart::GGPlot::Layer-E<gt>new()>.
These are often aesthetics, used to set an aesthetic to a fixed value,
like C<color =E<gt> "red", size =E<gt> 3>.
They may also be parameters to the paired geom/stat.
 
=back
 
=head2 geom_line
 
    geom_line(:$mapping=undef, :$data=undef, :$stat='identity',
              :$position='identity', :$na_rm=false, :$show_legend=undef,
              :$inherit_aes=true,
              %rest)
 
The "line" geom connects the observations in the order of the variable
on the x axis.
 
Arguments:
 
=over 4

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
These are often aesthetics, used to set an aesthetic to a fixed value,
like C<color =E<gt> "red", size =E<gt> 3>.
They may also be parameters to the paired geom/stat.
 
=back
 
=head2 geom_polygon
 
    geom_polygon(:$mapping=undef, :$data=undef,
                 :$stat='identity', :$position='identity',
                 :$na_rm=false, :$show_legend=undef,
                 :$inherit_aes=true,
                 %rest)
 
Polygons are very similar to paths (as drawn by C<geom_path()>)
except that the start and end points are connected and the inside is
colored by the C<fill> aesthetic. The C<group> aesthetic determines
which cases are connected together into a polygon.
 
=over 4

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
These are often aesthetics, used to set an aesthetic to a fixed value,
like C<color =E<gt> "red", size =E<gt> 3>.
They may also be parameters to the paired geom/stat.
 
=back
 
=head2 geom_rect
 
    geom_rect(:$mapping=undef, :$data=undef, :$stat='count',
              :$position='stack', :$width=undef,
              :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
              %rest)
 
C<geom_rect()> uses the locations of the four corners
(aethetics C<xmin>, C<xmax>, C<ymin> and C<ymax>) to define rectangles.
 
Arguments:
 
=over 4
 
=item * $mapping

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
These are often aesthetics, used to set an aesthetic to a fixed value,
like C<color =E<gt> "red", size =E<gt> 3>.
They may also be parameters to the paired geom/stat.
 
=back
 
=head2 geom_tile
 
    geom_tile(:$mapping=undef, :$data=undef, :$stat='count',
              :$position='stack', :$width=undef,
              :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
              %rest)
 
C<geom_tile()> uses the center of the tile and its size
(aesthetics C<x>, C<y>, C<width> and C<height>) to define rectangles.
 
Arguments:
 
=over 4
 
=item * $mapping

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
like C<color =E<gt> "red", size =E<gt> 3>.
They may also be parameters to the paired geom/stat.
 
=back
 
=head2 geom_raster
 
    geom_raster(:$mapping=undef, :$data=undef, :$stat='count',
                Num :$hjust=0.5, Num :$vjust=0.5,
                :$position='stack', :$width=undef,
                :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                %rest)
 
C<geom_raster()> is a high performance special case of C<geom_tile()>
for when all the tiles are the same size.
 
Arguments:
 
=over 4
 
=item * $mapping

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
like C<color =E<gt> "red", size =E<gt> 3>.
They may also be parameters to the paired geom/stat.
 
=back
 
=head2 geom_smooth
 
    geom_smooth(:$mapping=undef, :$data=undef,
                :$stat='smooth', :$position='identity',
                :$method='auto', :$se=true,
                :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                %rest)
 
Aids the eye in seeing patterns in the presence of overplotting, by
calculating a smoothed conditional mean.
 
C<geom_smooth()> and C<stat_smooth()> are effectively aliases: they
both use the same arguments. Use C<stat_smooth()> if you want to
display the results with a non-standard geom.
 
Arguments:

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
They may also be parameters to the paired geom/stat.
 
=back
 
See also L<Chart::GGPlot::Stat::Functions/stat_smooth>.
 
=head2 geom_text
 
    geom_text(:$mapping=undef, :$data=undef, :$stat='identity',
              :$position='identity',
              :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
              %rest)
 
C<geom_text()> adds text to the plot.
 
Arguments:
 
=over 4
 
=item * $mapping

lib/Chart/GGPlot/Geom/Functions.pm  view on Meta::CPAN

948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
=item * $position
 
Position adjustment, either as a string, or the result of a call to a
position adjustment function.
 
=item * $na_rm
 
If false, the default, missing values are removed with a warning.
If true, missing values are silently removed.
 
=item * $show_legend
 
Should this layer be included in the legends?
C<undef>, the default, includes if any aesthetics are mapped.
A true scalar for never includes, and a defined false scalar for always
includes.
 
=item * $inherit_aes
 
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.

lib/Chart/GGPlot/Geom/Line.pm  view on Meta::CPAN

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
extends qw(https://metacpan.org/pod/Chart::GGPlot::Geom::Path">Chart::GGPlot::Geom::Path);
 
our $VERSION = '0.002003'; # VERSION
 
use Chart::GGPlot::Util::Pod qw(layer_func_pod);
 
my $geom_line_pod = layer_func_pod(<<'EOT');
 
        geom_line(:$mapping=undef, :$data=undef, :$stat='identity',
                  :$position='identity', :$na_rm=false, :$show_legend=undef,
                  :$inherit_aes=true,
                  %rest)
 
    The "line" geom connects the observations in the order of the variable
    on the x axis.
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =back
 
EOT
 
my $geom_line_code = fun (
        :$mapping = undef, :$data = undef,
        :$stat = 'identity', :$position = 'identity',
        :$na_rm = false,
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        geom        => 'line',
        params      => { na_rm => $na_rm, %rest },
    );
};
 
classmethod ggplot_functions() {
    return [
        {
            name => 'geom_line',

lib/Chart/GGPlot/Geom/Path.pm  view on Meta::CPAN

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
            alpha    => NA(),
        );
    }
);
 
classmethod required_aes () { [qw(x y)] }
 
my $geom_path_pod = layer_func_pod(<<'EOT');
 
        geom_path(:$mapping=undef, :$data=undef, :$stat='identity',
                  :$position='identity', :$na_rm=false, :$show_legend=undef,
                  :$inherit_aes=true,
                  %rest)
 
    The "path" geom connects the observations in the order in which they
    appear in the data.
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =back
 
EOT
 
my $geom_path_code = fun (
        :$mapping = undef, :$data = undef,
        :$stat = 'identity', :$position = 'identity',
        :$na_rm = false,
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        geom        => 'path',
        params      => { na_rm => $na_rm, %rest },
    );
};
 
classmethod ggplot_functions() {
    return [
        {
            name => 'geom_path',

lib/Chart/GGPlot/Geom/Point.pm  view on Meta::CPAN

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
        );
    }
);
 
classmethod required_aes() { [qw(x y)] }
 
my $geom_point_pod = layer_func_pod(<<'EOT');
 
        geom_point(:$mapping=undef, :$data=undef, :$stat='identity',
                   :$position='identity',
                   :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                   %rest)
 
    The "point" geom is used to create scatterplots.
    The scatterplot is most useful for displaying the relationship between
    two continuous variables.
    A bubblechart is a scatterplot with a third variable mapped to the size
    of points.
 
    Arguments:

lib/Chart/GGPlot/Geom/Point.pm  view on Meta::CPAN

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    %TMPL_COMMON_ARGS%
 
    =back
 
EOT
 
my $geom_point_code = fun (
        :$mapping = undef, :$data = undef,
        :$stat = 'identity', :$position = 'identity',
        :$na_rm = false,
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        geom        => 'point',
        params      => { na_rm => $na_rm, %rest },
    );
};
 
classmethod ggplot_functions() {
    return [
        {
            name => 'geom_point',

lib/Chart/GGPlot/Geom/Polygon.pm  view on Meta::CPAN

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
        );
    }  
);
 
classmethod required_aes() { [qw(x y)] }
 
my $geom_polygon_pod = layer_func_pod(<<'EOT');
 
        geom_polygon(:$mapping=undef, :$data=undef,
                     :$stat='identity', :$position='identity',
                     :$na_rm=false, :$show_legend=undef,
                     :$inherit_aes=true,
                     %rest)
 
    Polygons are very similar to paths (as drawn by C<geom_path()>)
    except that the start and end points are connected and the inside is
    colored by the C<fill> aesthetic. The C<group> aesthetic determines
    which cases are connected together into a polygon.
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =back
 
EOT
 
my $geom_polygon_code = fun (
        :$mapping = undef, :$data = undef,
        :$stat = 'identity', :$position = 'identity',
        :$width = undef, :$na_rm = false,
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        geom        => 'polygon',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            na_rm => $na_rm,
            %rest,
        },
    );
};
 
classmethod ggplot_functions() {
    return [

lib/Chart/GGPlot/Geom/Raster.pm  view on Meta::CPAN

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
classmethod require_aes () { [qw(x y)] }
classmethod extra_params () { [qw(na_rm)] }
classmethod _parameters () { [qw(hjust vjust interpolate)] }
 
my $geom_raster_pod = layer_func_pod(<<'EOT');
 
        geom_raster(:$mapping=undef, :$data=undef, :$stat='count',
                    Num :$hjust=0.5, Num :$vjust=0.5,
                    :$position='stack', :$width=undef,
                    :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                    %rest)
 
    C<geom_raster()> is a high performance special case of C<geom_tile()>
    for when all the tiles are the same size.
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =back
 
EOT
 
my $geom_raster_code = fun(
    :$mapping = undef, :$data = undef,
    :$stat = 'identity', :$position = 'identity',
    Num :$hjust = 0.5, Num :$vjust = 0.5,
    #:$interpolate = false,
    :$na_rm = false, :$show_legend = undef, :$inherit_aes = true,
    %rest)
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        geom        => 'raster',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            na_rm       => $na_rm,
            hjust       => $hjust,
            vjust       => $vjust,
            #interpolate => $interpolate,
            %rest
        },
    );
};

lib/Chart/GGPlot/Geom/Rect.pm  view on Meta::CPAN

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        );
    }
);
 
classmethod required_aes() { [qw(xmin xmax ymin ymax)] };
 
my $geom_rect_pod = layer_func_pod(<<'EOT');
 
        geom_rect(:$mapping=undef, :$data=undef, :$stat='count',
                  :$position='stack', :$width=undef,
                  :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                  %rest)
 
    C<geom_rect()> uses the locations of the four corners
    (aethetics C<xmin>, C<xmax>, C<ymin> and C<ymax>) to define rectangles.
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =back
 
EOT
 
my $geom_rect_code = fun(
    :$mapping = undef, :$data = undef,
    :$stat = 'identity', :$position = 'identity',
    :$na_rm = false, :$show_legend = undef, :$inherit_aes = true,
    %rest)
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        geom        => 'rect',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            na_rm => $na_rm,
            %rest
        },
    );
};
 
classmethod ggplot_functions () {
    return [

lib/Chart/GGPlot/Geom/Smooth.pm  view on Meta::CPAN

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
);
 
classmethod required_aes() { [qw(x y)] }
classmethod optional_aes() { [qw(ymin ymax)] }
 
my $geom_smooth_pod = layer_func_pod(<<'EOT');
 
        geom_smooth(:$mapping=undef, :$data=undef,
                    :$stat='smooth', :$position='identity',
                    :$method='auto', :$se=true,
                    :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                    %rest)
 
    Aids the eye in seeing patterns in the presence of overplotting, by
    calculating a smoothed conditional mean.
 
    C<geom_smooth()> and C<stat_smooth()> are effectively aliases: they
    both use the same arguments. Use C<stat_smooth()> if you want to
    display the results with a non-standard geom.
 
    Arguments:

lib/Chart/GGPlot/Geom/Smooth.pm  view on Meta::CPAN

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    See also L<Chart::GGPlot::Stat::Functions/stat_smooth>.
 
EOT
 
my $geom_smooth_code = fun (
        :$mapping = undef, :$data = undef,
        :$stat = 'smooth', :$position = 'identity',
        :$method = 'auto',
        :$se = true,
        :$na_rm = false, :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        geom        => 'smooth',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            na_rm  => $na_rm,
            se     => $se,
            method => $method,
            %rest
        },
    ); 
};

lib/Chart/GGPlot/Geom/Text.pm  view on Meta::CPAN

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
        );
    }
);
 
classmethod required_aes() { [qw(x y label)] }
 
my $geom_text_pod = layer_func_pod(<<'EOT');
 
        geom_text(:$mapping=undef, :$data=undef, :$stat='identity',
                  :$position='identity',
                  :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                  %rest)
 
    C<geom_text()> adds text to the plot.
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%

lib/Chart/GGPlot/Geom/Text.pm  view on Meta::CPAN

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    =back
 
EOT
 
my $geom_text_code = fun(
    : $mapping     = undef,
    : $data        = undef,
    : $stat        = 'identity',
    : $position    = 'identity',
    : $na_rm       = false,
    : $show_legend = undef,
    : $inherit_aes = true,
    %rest
  )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        geom        => 'text',
        params      => { na_rm => $na_rm, %rest },
    );
};
 
classmethod ggplot_functions() {
    return [
        {
            name => 'geom_text',

lib/Chart/GGPlot/Geom/Tile.pm  view on Meta::CPAN

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    }
);
 
classmethod require_aes () { [qw(x y)] }
classmethod extra_params () { [qw(na_rm)] }
 
my $geom_tile_pod = layer_func_pod(<<'EOT');
 
        geom_tile(:$mapping=undef, :$data=undef, :$stat='count',
                  :$position='stack', :$width=undef,
                  :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                  %rest)
 
    C<geom_tile()> uses the center of the tile and its size
    (aesthetics C<x>, C<y>, C<width> and C<height>) to define rectangles.
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =back
 
EOT
 
my $geom_tile_code = fun(
    :$mapping = undef, :$data = undef,
    :$stat = 'identity', :$position = 'identity',
    :$na_rm = false, :$show_legend = undef, :$inherit_aes = true,
    %rest)
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => $stat,
        geom        => 'tile',
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            na_rm => $na_rm,
            %rest
        },
    );
};
 
classmethod ggplot_functions () {
    return [

lib/Chart/GGPlot/Guide/Functions.pm  view on Meta::CPAN

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
our $VERSION = '0.002003'; # VERSION
 
 
 
our @EXPORT_OK = qw(
  guide_legend
);
our %EXPORT_TAGS = (
    'all'    => \@EXPORT_OK,
    'ggplot' => [qw(guide_legend)],
);
 
 
sub guide_legend {
    return Chart::GGPlot::Guide::Legend->new(@_);  
}
 
 
1;
 
__END__
 
=pod

lib/Chart/GGPlot/Guide/Functions.pm  view on Meta::CPAN

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
=head1 NAME
 
Chart::GGPlot::Guide::Functions - Function interface for guides
 
=head1 VERSION
 
version 0.002003
 
=head1 FUNCTIONS
 
=head2 guide_legend
 
    guide_legend(:$title=undef, %rest)
 
=head1 SEE ALSO
 
L<Chart::GGPlot::Guide>
 
=head1 AUTHOR
 
Stephan Loyd <sloyd@cpan.org>
 
=head1 COPYRIGHT AND LICENSE

lib/Chart/GGPlot/Guides.pm  view on Meta::CPAN

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
    );
}
 
$guide = $guide->train($scale, $output);
next unless defined $guide;
 
if (
    List::AllUtils::none {
        my $matched =
          $self->_matched_aes( $_, $guide, $default_mapping );
        my $show_legend = $_->show_legend;
        ( $matched->length > 0
              and ( not defined $show_legend or $show_legend ) )
    }
    @$layers
  )
{
    next;
}
 
if (defined $guide) {
    push @gdefs, $guide;
}

lib/Chart/GGPlot/Labels.pm  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
# ABSTRACT: Axis, legend, and plot labels
 
 
our $VERSION = '0.002003'; # VERSION
 
 
1;
 
__END__
 
=pod
 
=encoding UTF-8
 
=head1 NAME
 
Chart::GGPlot::Labels - Axis, legend, and plot labels
 
=head1 VERSION
 
version 0.002003
 
=head1 DESCRIPTION
 
This class inherits L<Chart::GGPlot::Aes>.
Now it actually does nothing more than its parent class, but is just for
having its own type which is used by L<Chart::GGPlot::Plot>.

lib/Chart/GGPlot/Layer.pm  view on Meta::CPAN

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
);
has aes_params => (
    is     => 'rw',
    isa    => AesMapping,
    coerce => 1,
);
has position    => ( is => 'ro', required => 1 );
has inherit_aes => ( is => 'ro', default  => sub { false } );
 
 
has show_legend => ( is => 'ro' );
 
around BUILDARGS( $orig, $class : @rest ) {
    my %params = @rest;
    return $class->$orig( %{ $class->_layer(%params) } );
};
 
classmethod _find_subclass ($super, $name) {
    return (
          $name =~ /^Chart::GGPlot::/
        ? $name
        : "Chart::GGPlot::${super}::"
          . join( '', map { ucfirst($_) } split( /_/, $name ) )
    );
}
 
classmethod _layer (Defined :$geom, Defined :$stat,
                    :$data = undef, :$mapping = undef,
                    Defined :$position,
                    :$params = { na_rm => false },
                    :$inherit_aes = true, :$check_aes = true,
                    :$check_param = true, :$show_legend = NA
  ) {
    $mapping //= Chart::GGPlot::Aes->new();
    unless ( defined $params->at("na_rm") ) {
        $params->set( "na_rm", "nan" );
    }
 
    my $find_subclass = fun( $super, $x ) {
        unless ( Ref::Util::is_ref($x) ) {  # $x is a class name
            my $subclass = $class->_find_subclass( $super, $x );
            load $subclass;

lib/Chart/GGPlot/Layer.pm  view on Meta::CPAN

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
        carp( "Ignoring unknown aesthetics: " . join( ", ", @extra_aes ) );
    }
 
    return {
        geom        => $geom,
        stat        => $stat,
        data        => $data,
        mapping     => $mapping,
        position    => $position,
        inherit_aes => $inherit_aes,
        show_legend => $show_legend,
        geom_params => $geom_params,
        stat_params => $stat_params,
        aes_params  => $aes_params,
    };
}
 
 
method string () {
    my $s = '';
    if ( $self->mapping ) {

lib/Chart/GGPlot/Layer.pm  view on Meta::CPAN

378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
If false, overrides the default aesthetics, rather than combining with them.
This is most useful for helper functions that define both data and
aesthetics and shouldn't inherit behaviour from the default plot
specification.
 
=head2 params
 
Additional parameters to the "geom" and "stat".
 
=head2 show_legend
 
Should this layer be included in the legends?
 
=over 4
 
=item *
 
C<undef>, includes if any aesthetics are mapped.
 
=item *
 
A defined true scalar (non-Chart::GGPlot::Aes), never includes.

lib/Chart/GGPlot/Position/Dodge2.pm  view on Meta::CPAN

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
=head2 padding
 
Padding between elements at the same position.
Elements are shrunk by this proportion to allow space between them.
Defaults to 0.1.
 
=head2 reverse
 
If true, will reverse the default stacking order.
This is useful if you're rotating both the plot and legend.
 
=head1 SEE ALSO
 
L<Chart::GGPlot::Position>,
L<Chart::GGPlot::Position::Dodge>,
 
=head1 AUTHOR
 
Stephan Loyd <sloyd@cpan.org>

lib/Chart/GGPlot/Position/Stack.pm  view on Meta::CPAN

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
=head1 DESCRIPTION
 
This stacks bars on top of each other.
 
=head1 ATTRIBUTES
 
=head2 reverse
 
If true, will reverse the default stacking order.
This is useful if you're rotating both the plot and legend.
Default is false.
 
=head1 SEE ALSO
 
L<Chart::GGPlot::Position>
 
=head1 AUTHOR
 
Stephan Loyd <sloyd@cpan.org>

lib/Chart/GGPlot/Position/Util.pm  view on Meta::CPAN

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
}
 
fun collide ($data, $width, $name, $strategy,
             :$check_width=true, :$reverse=false, %rest) {
    my $dlist =
      collide_setup( $data, $width, $name, $strategy, $check_width, $reverse );
    $data  = $dlist->{data};
    $width = $dlist->{width};
 
    # Reorder by x position, then on group. The default stacking order
    # reverses the group in order to match the legend order.
    $data = $data->sort( [qw(xmin group)], $reverse ? true : [ true, false ] );
 
    # TODO: ddply to preserve the order.
    #  So firstly DF::split() shall preserve the order.
    state $ddply = sub {
        my ( $df, $vars, $func ) = @_;
 
        my $ids         = $df->select_columns($vars)->id;
        my $splitted    = $df->split($ids);
        my @transformed = map { $func->($_) } values %$splitted;

lib/Chart/GGPlot/Scale.pm  view on Meta::CPAN

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    is      => 'rw',
    default => sub { null; },
);
 
has na_value => ( is => 'rw', default => "nan" );
has expand   => ( is => 'rw', default => undef );
has name     => ( is => 'rw', default => undef );
has breaks   => ( is => 'rw', default => undef );
has labels =>
  ( is => 'rw', isa => Maybe [ Piddle | CodeRef ], default => undef );
has guide    => ( is => 'ro', default => "legend" );
has position => ( is => 'rw', isa     => PositionEnum, default => "left" );
has trans    => ( is => 'rw', isa     => InstanceOf ["Chart::GGPlot::Trans"] );
 
requires 'train';    # Train an individual scale from a vector of data.
requires 'transform';
 
requires 'get_breaks_minor';
requires 'get_labels';
requires 'break_info';
requires 'dimension';

lib/Chart/GGPlot/Scale.pm  view on Meta::CPAN

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
A palette function that when called with a single integer
argument (the number of levels in the scale) returns the values that
they should take.
 
=head2 limits
 
A numeric vector of length two providing limits of the scale.
 
=head2 name
 
Used as axis or legend title. If C<undef>, the default, it's taken from
the first mapping used for that aesthetic. If C<null> or C<[]>, the legend
title will be omitted.
 
=head2 breaks
 
One of
 
=over 4
 
=item *

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
    return ($breaks, $labels);
}
 
 
fun continuous_scale (:$aesthetics, :$scale_name,
                      :$palette, :$name=undef,
                      :$breaks=undef, :$minor_breaks=undef,
                      :$labels=undef, :$limits=null(),
                      :$rescaler=\&rescale, :$oob=\&censor, :$expand=undef,
                      :$na_value='nan',
                      :$trans="identity", :$guide="legend",
                      PositionEnum :$position="left",
                      Str :$super='Chart::GGPlot::Scale::Continuous',
                      %rest
  ) {
    ($breaks, $labels) = _check_breaks_labels( $breaks, $labels );
 
    if (    ( defined $breaks and $breaks->isempty )
        and !is_position_aes($aesthetics)
        and $guide ne "none" )
    {

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
        )
    );
}
 
 
fun discrete_scale (:$aesthetics, :$scale_name,
                    :$palette, :$name=undef,
                    :$breaks=undef, :$labels=undef,
                    :$limits=PDL::SV->new([]),
                    :$expand=undef, :$na_translate=true, :$na_value=undef,
                    :$drop=true, :$guide="legend",
                    PositionEnum :$position = "left",
                    Str :$super = 'Chart::GGPlot::Scale::Discrete',
                    %rest
  ) {
    ($breaks, $labels) = _check_breaks_labels( $breaks, $labels );
 
    if (    ( defined $breaks and $breaks->isempty )
        and !is_position_aes($aesthetics)
        and $guide ne "none" )
    {

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
        my $scale_func      = "scale_${aes}_${trans}";
        my $continuous_func = "scale_${aes}_continuous";
        no strict 'refs';
        *{$scale_func} = sub { $continuous_func->( @_, trans => $trans ) }
    }
}
 
 
fun scale_size_continuous (:$name=undef, :$breaks=undef, :$labels=undef,
                          :$limits=[], :$range=[1, 6],
                          :$trans='identity', :$guide='legend') {
    return continuous_scale(
        pairgrep { defined $b } (
            aesthetics => 'size',
            scale_name => 'area',
            palette    => area_pal($range),
            name       => $name,
            breaks     => $breaks,
            labels     => $labels,
            limits     => $limits,
            trans      => $trans,

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
#        :$limits = undef, :$expand = undef,
#        PositionEnum :$position = "left",
#        :$sec_axis = undef)
 
 
fun datetime_scale (:$aesthetics, :$trans, :$palette,
                    :$breaks = pretty_breaks(), :$minor_breaks = undef,
                    :$labels = undef, :$date_breaks = undef,
                    :$date_labels = undef,
                    :$date_minor_breaks = undef, :$timezone = undef,
                    :$guide = 'legend',
                    %rest) {
 
    # TODO: handle timezone
 
    if ( defined $date_breaks ) {
        $breaks = date_breaks($date_breaks);
    }
    if ( defined $date_minor_breaks ) {
        $minor_breaks = date_breaks($date_minor_breaks);
    }

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
Find scale function by aes name and data type. The scale function is in the
form of C<scale_${aes}_${type}>, where C<$type> is decided by C<$x>.
 
=head2 continuous_scale
 
    continuous_scale (:$aesthetics, :$scale_name, :$palette, :$name=undef,
        :$breaks=undef, :$minor_breaks=undef, :$labels=undef,
        :$limits=null(), :$rescaler=\&rescale, :$oob=\&censor,
        :$expand=undef, :$na_value='nan', :$trans="identity",
        :$guide="legend", PositionEnum :$position="left",
        Str :$super='Chart::GGPlot::Scale::Continuous',
        %rest)
 
Continuous scale constructor.
It's internally used by the continous scales in this module.
 
Arguments:
 
=over 4

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
The name of the scale.
 
=item * $palette
 
A palette function that when called with a numeric piddle with values
between 0 and 1 returns the corresponding values in the range the scale maps
to.
 
=item * $name
 
The name of the scale. Used as the axis or legend title.
If C<undef>, the default, the name of the scale is taken from the first
mapping used for that aesthetic.
 
=item * $breaks
 
Major breaks.
 
One of:
 
=over 8

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
The class to use for the constructed scale.
Default is L<Chart::GGPlot::Scale::Continuous>.
 
=back
 
=head2 discrete_scale
 
    discrete_scale(:$aesthetics, :$scale_name, :$palette, :$name=undef,
        :$breaks=undef, :$labels=undef, :$limits=PDL::SV->new([]),
        :$expand=undef, :$na_translate=true, :$na_value=undef,
        :$drop=true, :$guide="legend", PositionEnum :$position = "left",
        Str :$super = 'Chart::GGPlot::Scale::Discrete',
        %rest)
 
Discrete scale constructor.
It's internally used by the discrete scales in this module.
 
Arguments:
 
=over 4

lib/Chart/GGPlot/Scale/Functions.pm  view on Meta::CPAN

946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
The name of the scale.
 
=item * $palette
 
A palette function that when called with a single argument (the number of
levels in the scale) returns the values that they should take.
 
=item * $name
 
The name of the scale. Used as the axis or legend title.
If C<undef>, the default, the name of the scale is taken from the first
mapping used for that aesthetic.
 
=item * $breaks
 
Major breaks.
 
One of:
 
=over 8

lib/Chart/GGPlot/Stat/Bin.pm  view on Meta::CPAN

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    ]
}
 
my $stat_bin_pod = layer_func_pod(<<'EOT');
 
        stat_bin(:$mapping=undef, :$data=undef,
                 :$geom="bar", :$position="stack",
                 :$binwidth=undef, :$bins=undef,
                 :$center=undef, :$boundary=undef, :$breaks=undef,
                 :$pad=false,
                 :$na_rm=false, :$show_legend='auto', :$inherit_aes=true,
                 %rest)
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =item * $binwidth

lib/Chart/GGPlot/Stat/Bin.pm  view on Meta::CPAN

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
EOT
 
my $stat_bin_code = fun (
    :$mapping=undef, :$data=undef,
    :$geom="bar", :$position="stack",
    :$binwidth=undef, :$bins=undef,
    :$center=undef, :$boundary=undef, :$breaks=undef,
    :$pad=false,
    :$na_rm=false,
    :$show_legend='auto', :$inherit_aes=true,
    %rest )
{                          
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => 'bin',
        geom        => $geom,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            binwidth => $binwidth,
            bins     => $bins,
            center   => $center,
            boundary => $boundary,
            breaks   => $breaks,
            pad      => $pad,
            na_rm    => $na_rm,
            %rest

lib/Chart/GGPlot/Stat/Boxplot.pm  view on Meta::CPAN

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
          bins binwidth boundary breaks center pad
          )
    ]
}
 
my $stat_boxplot_pod = layer_func_pod(<<'EOT');
 
        stat_boxplot(:$mapping=undef, :$data=undef,
                     :$geom='boxplot', :$position='dodge2',
                     :$coef=1.5,
                     :$na_rm=false, :$show_legend='auto', :$inherit_aes=true,
                     %rest)
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =item * $coef
 
    Length of the whiskers as multiple of IQR. Defaults to 1.5.
 
    =back
 
EOT
 
my $stat_boxplot_code = fun (
        :$mapping=undef, :$data=undef,
        :$geom='boxplot', :$position='dodge2',
        :$coef=1.5, :$na_rm=false,
        :$show_legend='auto', :$inherit_aes=true,
        %rest )
{
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => 'boxplot',
        geom        => $geom,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => {
            na_rm => $na_rm,
            coef  => $coef,
            %rest,
        }
    );
};
 
classmethod ggplot_functions () {

lib/Chart/GGPlot/Stat/Count.pm  view on Meta::CPAN

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    }
);
 
classmethod required_aes() { ['x'] }
 
my $stat_count_pod = layer_func_pod(<<'EOT');
 
        stat_count(:$mapping=undef, :$data=undef,
                   :$geom='bar', :$position='stack',
                   :$width=undef,
                   :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
                   %rest)
 
    Arguments:
 
    =over 4
 
    %TMPL_COMMON_ARGS%
 
    =item * $width
 
    Bar width. By default, set to 90% of the resolution of the data.
 
    =back
 
EOT
 
my $stat_count_code = fun (
        :$mapping = undef, :$data = undef,
        :$geom = 'bar', :$position = 'stack',
        :$width = undef, :$na_rm = false,
        :$show_legend = undef, :$inherit_aes = true,
        %rest )
{
    my $params = {
        na_rm => $na_rm,
        width => $width,
        %rest
    }; 
    if ( $data->exists('y') ) {
        die "stat_count() must not be used with a y aesthetic.";
    }  
 
    return Chart::GGPlot::Layer->new(
        data        => $data,
        mapping     => $mapping,
        stat        => 'count',
        geom        => $geom,
        position    => $position,
        show_legend => $show_legend,
        inherit_aes => $inherit_aes,
        params      => $params,
    ); 
};
 
classmethod ggplot_functions() {
    return [
        {
            name => 'stat_count',
            code => $stat_count_code,



( run in 0.398 second using v1.01-cache-2.11-cpan-8d75d55dd25 )