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

Chart::GGPlot::Scale::Functions - Scale functions

VERSION

version 0.002003

FUNCTIONS

find_scale($aes, $x)

Find scale function by aes name and data type. The scale function is in the form of scale_${aes}_${type}, where $type is decided by $x.

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:

  • $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 numeric piddle with values between 0 and 1 returns the corresponding values in the range the scale maps to.

  • $name

    The name of the scale. Used as the axis or legend title. If undef, the default, the name of the scale is taken from the first mapping used for that aesthetic.

  • $breaks

    Major breaks.

    One of:

    • An empty piddle for no breaks

    • undef for default breaks computed by the transformation object

    • A numeric piddle of positions

    • A function that given the limits and returns a piddle of breaks

  • $minor_breaks

    One of:

    • An empty piddle for no minor breaks

    • undef for the default breaks (one minor break betwen each major break)

    • A numeric piddle of positions

    • A function that given the limits and return a piddle of minor breaks

  • $labels

    One of:

    • An empty piddle for no labels

    • undef for the default labels computed by the transformation object

    • A PDL::SV piddle giving labels (must be same length as $breaks)

    • A function that given the breaks and returns labels

  • $limits

    A numeric piddle of length two providing limits of the scale. Use BAD to refer to the existing minimum or maximum.

  • $rescaler

    A function used to scale the input values to the range [0, 1]. Used by diverging and n color gradients (i.e. scale_color_gradient2(), scale_colour_gradientn()).

  • $oob

    Function that handles limits outside of the scale limits (out of bounds). The default replaces out of bounds values with BAD.

  • $expand

    Vector of range expansion constants used to add some padding around the data, to ensure that they are placed some distance away from the axes. Use the convenience function expand_scale() to generate the values for the expand argument. The defaults are to expand the scale by 5% on each side for continuous variables, and by 0.6 units on each side for discrete variables.

  • $na_value

    Missing values will be replaced with this value.

  • $trans

    Either the name of a transformation object, or the object itself. See Chart::GGPlot::Trans::Functions for built-in transformations. Default is "identity".

  • $guide

    A function used to create a guide or its name.

  • $position

    The position of the axis. "left" or "right" for vertical scales, "top" or "bottom" for horizontal scales.

  • super

    The class to use for the constructed scale. Default is Chart::GGPlot::Scale::Continuous.

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:

  • $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 argument (the number of levels in the scale) returns the values that they should take.

  • $name

    The name of the scale. Used as the axis or legend title. If undef, the default, the name of the scale is taken from the first mapping used for that aesthetic.

  • $breaks

    Major breaks.

    One of:

    • An empty piddle for no breaks

    • undef for default breaks computed by the transformation object

    • A PDL::SV piddle of positions

    • A function that given the limits and returns a piddle of breaks

  • $minor_breaks

    One of:

    • An empty piddle for no minor breaks

    • undef for the default breaks (one minor break betwen each major break)

    • A PDL::SV piddle of positions

    • A function that given the limits and return a piddle of minor breaks

  • $labels

    One of:

    • An empty piddle for no labels

    • undef for the default labels computed by the transformation object

    • A PDL::SV piddle giving labels (must be same length as $breaks)

    • A function that given the breaks and returns labels

  • $limits

    A PDL::SV piddle of length two providing limits of the scale. Use BAD to refer to the existing minimum or maximum.

  • $expand

    Vector of range expansion constants used to add some padding around the data, to ensure that they are placed some distance away from the axes. Use the convenience function expand_scale() to generate the values for the expand argument. The defaults are to expand the scale by 5% on each side for continuous variables, and by 0.6 units on each side for discrete variables.

  • $na_translate

    Unlike continuous scales, discrete scales can easily show missing values, and do so by default. If you want to remove missing values from a discrete scale, specify na_translate =gt 0.

  • $na_value

    Missing values will be replaced with this value.

  • $drop

    Should unused factor levels be omitted from the scale? The default, true, uses the levels that appear in the data; false uses all the levels in the factor.

  • $guide

    A function used to create a guide or its name.

  • $position

    The position of the axis. "left" or "right" for vertical scales, "top" or "bottom" for horizontal scales.

  • super

    The class to use for the constructed scale. Default is Chart::GGPlot::Scale::Discrete.

scale_color_hue

    scale_color_hue(:$h = pdl( [ 0, 360 ] ) + 15, :$c = 100, :$l = 65,
        :$h_start = 0, :$direction = 1, :$na_value = 'grey50',
        %rest)

scale_color_discrete

This is same as the scale_color_hue() function.

scale_fill_hue

    scale_fill_hue(:$h = pdl( [ 0, 360 ] ) + 15, :$c = 100, :$l = 65,
        :$h_start = 0, :$direction = 1, :$na_value = 'grey50',
        %rest)

scale_fill_discrete

This is same as the scale_fill_hue() function.

scale_color_brewer

    scale_color_brewer(ColorBrewerTypeEnum :$type = "seq",
        :$palette = 0, :$direction = 1,
        %rest)

scale_fill_brewer

    scale_fill_brewer(ColorBrewerTypeEnum :$type = "seq",
        :$palette = 0, :$direction = 1,
        %rest)

scale_color_distiller

    scale_color_distiller(ColorBrewerTypeEnum :$type = "seq",
        :$palette = 1, :$direction = -1,
        :$values = [], :$na_value = "grey50", :$guide = "colorbar",
        %rest)

scale_fill_distiller

    scale_fill_distiller(ColorBrewerTypeEnum :$type = "seq",
        :$palette = 1, :$direction = -1,
        :$values = [], :$na_value = "grey50", :$guide = "colorbar",
        %rest)

scale_color_gradient

    scale_color_gradient(:$low = "#132B43", :$high = "#56B1F7",
        :$na_value = "grey50", :$guide = "colorbar",
        %rest)

scale_fill_gradient

    scale_fill_gradient(:$low = "#132B43", :$high = "#56B1F7",
        :$na_value = "grey50", :$guide = "colorbar",
        %rest)

scale_color_gradient2

    scale_color_gradient2(:$low = muted("red"), :$mid = "white",
        :$high = muted("blue"), :$midpoint = 0, :$na_value = "grey50",
        :$guide = "colorbar",
        %rest)

scale_fill_gradient2

    scale_fill_gradient2(:$low = muted("red"), :$mid = "white",
        :$high = muted("blue"), :$midpoint = 0, :$na_value = "grey50",
        :$guide = "colorbar",
        %rest)

scale_color_gradientn

    scale_color_gradientn(:$colors, :$values = [],
        :$na_value = "grey50", :$guide = "colorbar",
        %rest)

scale_fill_gradientn

    scale_fill_gradientn(:$colors, :$values = [],
        :$na_value = "grey50", :$guide = "colorbar",
        %rest)

scale_color_viridis_d

    scale_color_viridis_d(:$begin = 0, :$end = 1,
        :$direction = 1, :$option = 'viridis',
        %rest)

scale_color_ordinal

This is same as the scale_color_viridis_d() function.

scale_fill_viridis_d

    scale_fill_viridis_d(:$begin = 0, :$end = 1,
        :$direction = 1, :$option = 'viridis',
        %rest)

scale_fill_ordinal

This is same as the scale_fill_viridis_d() function.

scale_color_viridis_c

    scale_color_viridis_c(:$begin = 0, :$end = 1,
        :$direction = 1, :$option = 'viridis', :$values = null(),
        :$na_value = 'grey50', :$guide = 'colorbar',
        %rest)

scale_fill_viridis_c

    scale_fill_viridis_c(:$begin = 0, :$end = 1,
        :$direction = 1, :$option = 'viridis', :$values = null(),
        :$na_value = 'grey50', :$guide = 'colorbar',
        %rest)

scale_color_continuous

    scale_color_continuous(:$type="gradient, %rest")

Depending on $type,

  • "gradient" calls scale_color_gradient(%rest)

  • "viridis" calls scale_color_viridis_c(%rest)

scale_fill_continuous

    scale_fill_continuous(:$type="gradient, %rest")

Depending on $type,

  • "gradient" calls scale_fill_gradient(%rest)

  • "viridis" calls scale_fill_viridis_c(%rest)

scale_alpha_continuous

scale_alpha

This is same as the scale_alpha_continuous() method.

scale_x_continuous

    scale_x_continuous(:$name = undef, :$breaks = undef,
        :$minor_breaks = undef, :$labels = undef, :$limits = [],
        :$expand = undef, :$oob = \&censor, :$na_value = 'nan',
        :$trans = 'identity', :$position = "bottom", :$sec_axis = undef,
        %rest)

scale_y_continuous

    scale_y_continuous(:$name = undef, :$breaks = undef,
        :$minor_breaks = undef, :$labels = undef, :$limits = [],
        :$expand = undef, :$oob = \&censor, :$na_value = 'nan',
        :$trans = 'identity', :$position = "left", :$sec_axis = undef,
        %rest)

scale_x_log10

    scale_x_log10(...)

scale_y_log10

    scale_y_log10(...)

scale_x_reverse

    scale_x_reverse(...)

scale_y_reverse

    scale_y_reverse(...)

scale_x_sqrt

    scale_x_sqrt(...)

scale_y_sqrt

    scale_y_sqrt(...)

scale_size_continuous

    scale_size_continuous(:$range=[1,6], %rest)

scale_size

This is same as the scale_size_continuous() function.

scale_size_discrete

    scale_size_discrete(:$range=[1,6], %rest)

scale_x_discrete

    scale_x_discrete(:$expand = undef, :$position = "bottom", %rest )

scale_y_discrete

    scale_y_discrete(:$expand = undef, :$position = "left", %rest )

scale_color_identity

    scale_color_identity(:$guide="none", %rest)

scale_fill_identity

    scale_fill_identity(:$guide="none", %rest)

scale_shape_identity

    scale_shape_identity(:$guide="none", %rest)

scale_linetype_identity

    scale_linetype_identity(:$guide="none", %rest)

scale_alpha_identity

    scale_alpha_identity(:$guide="none", %rest)

scale_size_identity

    scale_size_identity(:$guide="none", %rest)

scale_continuous_identity

    scale_continuous_identity(:$aesthetics, :$guide="none", %rest)

scale_discrete_identity

    scale_discrete_identity(:$aesthetics, :$guide="none", %rest)

scale_x_datetime

    scale_y_date(:$name = undef, :$breaks = undef,
        :$date_breaks = undef, :$labels = undef, :$date_labels = undef, 
        :$minor_breaks = undef, :$date_minor_breaks = undef,
        :$limits = undef, :$expand = undef,
        PositionEnum :$position = "bottom",
        :$sec_axis = undef)

scale_y_datetime

    scale_y_date(:$name = undef, :$breaks = undef,
        :$date_breaks = undef, :$labels = undef, :$date_labels = undef, 
        :$minor_breaks = undef, :$date_minor_breaks = undef,
        :$limits = undef, :$expand = undef,
        PositionEnum :$position = "left",
        :$sec_axis = undef)

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.