NAME

Chart::GGPlot::Scale - The role for scale

VERSION

version 0.002003

DESCRIPTION

This module is a Moose role for "scale".

For users of Chart::GGPlot you would mostly want to look at Chart::GGPlot::Scale::Functions instead.

ATTRIBUTES

aesthetics

The name of the aesthetics that this scale works with.

scale_name

The name of the scale.

palette

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.

limits

A numeric vector of length two providing limits of the scale.

name

Used as axis or legend title. If undef, the default, it's taken from the first mapping used for that aesthetic. If null or [], the legend title will be omitted.

breaks

One of

  • null or [] for no breaks.

  • undef for default breaks computed by the tranformation object.

  • a numeric vector of positions.

  • a function that takes the limits as input and returns breaks.

labels

One of

  • null or [] for no labels.

  • undef for default labels computed by the tranformation object.

  • a string vector of labels (must be same of length as breaks).

  • a function that takes the breaks as input and returns labels.

na_value

Missing values will be replaced with this value.

trans

Either the name of a transformation object, or the object itself. Built-in transformations include "asn", "atanh", "exp", "identity", "identity", "log", "log10", "log1p", etc. See Chart::GGPlot::Trans for details.

guide

A function used to create a guide or its name.

position

The position of the axis. Possible values are "left", "right", "top", "bottom".

METHODS

train_df($df)

Train scale from a dataframe. Adjust range of the scale according to column data.

reset()

Reset scale, untrain ranges.

transform_df

Returns an associative arrayref of transformed variables and their values.

map_df($df, $i=null)

This calls map_to_limits() on each of the scale's aesthetics. Returns an associative arrayref which maps aesthetics to processed column data.

map_to_limits($p, $limits=$self->get_limits)

Maps a piddle of data to the scale's limits. Returns a piddle of processed column data.

AUTHOR

Stephan Loyd <sloyd@cpan.org>

COPYRIGHT AND LICENSE

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.