Chart-GGPlot
view release on metacpan or search on metacpan
lib/Chart/GGPlot/Scale/Functions.pm view on Meta::CPAN
aesthetics => $aes,
scale_name => "viridis_c",
palette => $pal,
na_value => $na_value,
guide => $guide,
%rest,
);
};
}
*scale_color_viridis_c = _scale_viridis_c('color');
*scale_fill_viridis_c = _scale_viridis_c('fill');
fun scale_color_continuous (:$type = "gradient", %rest) {
state $switch = {
gradient => \&scale_color_gradient,
viridis => \&scale_color_viridis_c,
};
if ( my $func = $switch->{$type} ) {
return $func->(%rest);
}
die("Unknown scale type");
}
fun scale_fill_continuous (:$type = "gradient", %rest) {
state $switch = {
gradient => \&scale_fill_gradient,
viridis => \&scale_fill_viridis_c,
};
if ( my $func = $switch->{$type} ) {
return $func->(%rest);
}
die("Unknown scale type");
}
fun scale_alpha_continuous (:$range=[0, 1], %rest) {
return continuous_scale(
pairgrep { defined $b } (
aesthetics => "alpha",
scale_name => "alpha_c",
palette => rescale_pal($range),
%rest
)
);
}
*scale_alpha = \&scale_alpha_continuous;
fun _scale_position_continuous ($aes) {
return fun(:$name = undef, :$breaks = undef, :$minor_breaks = undef,
:$labels = undef, :$limits = [],
:$expand = undef, :$oob = \&censor, :$na_value = 'nan',
:$trans = 'identity', :$position = _default_position($aes),
:$sec_axis = undef,
%rest,
)
{
if ( defined $sec_axis ) {
if ( is_formula($sec_axis) ) {
$sec_axis = sec_axis($sec_axis);
}
if ( $sec_axis->$_isa('Chart::GGPlot::AxisSecondary') ) {
die(
"Secondary axes must be specified using a Chart::GGPlot::AxisSecondary object"
);
}
}
return continuous_scale(
pairgrep { defined $b } (
aesthetics => $aes,
scale_name => 'position_c',
palette => \&identity,
name => $name,
breaks => $breaks,
minor_breaks => $minor_breaks,
labels => $labels,
limits => $limits,
expand => $expand,
oob => $oob,
na_value => $na_value,
trans => $trans,
guide => "none",
position => $position,
( $sec_axis ? ( secondary_axis => $sec_axis ) : () ),
super => 'Chart::GGPlot::Scale::ContinuousPosition',
%rest
)
);
};
}
*scale_x_continuous = _scale_position_continuous(
[
qw(x xmin xmax xend xintercept xmin_final xmax_final xlower xmiddle xupper)
]
);
*scale_y_continuous = _scale_position_continuous(
[qw(y ymin ymax yend yintercept ymin_final ymax_final lower middle upper)]
);
for my $trans (qw(log10 reverse sqrt)) {
for my $aes (qw(x y)) {
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),
( run in 0.699 second using v1.01-cache-2.11-cpan-39bf76dae61 )