The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Data::Dataset::Classic::Anscombe - Anscombe classic dataset

VERSION

version 0.001

SYNOPSIS

 use Data::Dataset::Classic::Anscombe;
 use Chart::Plotly qw(show_plot);
 use Chart::Plotly::Plot;
 use Chart::Plotly::Trace::Scatter;
 
 my $anscombe_quartet = Data::Dataset::Classic::Anscombe::get();
 
 my $anscombe_plot = Chart::Plotly::Plot->new(layout => {
        xaxis => {
                domain => [0, 0.45]
                },
        yaxis => {
                domain => [0.55, 1]
                },
        yaxis2 => {
                domain => [0.55, 1],
                anchor => 'x2'
                },
        xaxis2 => {
                domain => [0.55, 1]
                },
        xaxis3 => {
                domain => [0, 0.45],
                anchor => 'y3'
                },
        yaxis3 => {
                domain => [0, 0.45]
                },
        yaxis4 => {
                anchor => 'x4',
                domain => [0, 0.45],
                },
        xaxis4 => {
                domain => [0.55, 1],
                anchor => 'y4'
                }
 });
 
 my $first_anscombe = Chart::Plotly::Trace::Scatter->new( 
        x => $anscombe_quartet->{'x1'},
        y => $anscombe_quartet->{'y1'},
        mode => 'markers',
        marker => {size => 20},
        name => 'I'
 );
 $anscombe_plot->add_trace($first_anscombe);
 my $second_anscombe = Chart::Plotly::Trace::Scatter->new( 
        x => $anscombe_quartet->{'x2'},
        y => $anscombe_quartet->{'y2'},
        xaxis => 'x2',
        yaxis => 'y2',
        mode => 'markers',
        marker => {size => 20},
        name => 'II'
 );
 $anscombe_plot->add_trace($second_anscombe);
 my $third_anscombe = Chart::Plotly::Trace::Scatter->new( 
        x => $anscombe_quartet->{'x3'},
        y => $anscombe_quartet->{'y3'},
        xaxis => 'x3',
        yaxis => 'y3',
        mode => 'markers',
        marker => {size => 20},
        name => 'III',
 );
 $anscombe_plot->add_trace($third_anscombe);
 my $fourth_anscombe = Chart::Plotly::Trace::Scatter->new( 
        x => $anscombe_quartet->{'x4'},
        y => $anscombe_quartet->{'y4'},
        xaxis => 'x4',
        yaxis => 'y4',
        mode => 'markers',
        marker => {size => 20},
        name => 'IV'
 );
 $anscombe_plot->add_trace($fourth_anscombe);
 
 show_plot($anscombe_plot)

METHODS

get

Returns the classic Anscombe dataset as a reference.

By default returns a hash ref with the column names as the keys and data as the values as an array ref. You can get the data in the format you want using the argument as and indicating a valid class in the namespace Data::Dataset::Classic::Adapter::*

SEE ALSO

Wikipedia: Anscombe's quartet

1;

AUTHOR

Pablo Rodríguez González <pablo.rodriguez.gonzalez@gmail.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2016 by Pablo Rodríguez González.

This is free software, licensed under:

  The MIT (X11) License