print "got min/max of $lin_min, $lin_max\n"; my $range = $max - $min; my $log_range = log($max)/log(10) - log($min)/log(10);
# Start by determining the order of magnitude of the max, min, and log range:
my $max_order_of_magnitude
= PDL::Graphics::Prima::Scaling::Linear::order_of_magnitude($max);
my $min_order_of_magnitude
= PDL::Graphics::Prima::Scaling::Linear::order_of_magnitude($min);
# ... and the log range?
# working here... really?
my $best_score = 100;
my $best_min_Tick;
my $best_max_Tick;
my $best_N_ticks_per_order;
for my $N_ticks_per_order (0.5, 1, 2, 3);
# The ticks will start at either a multiple of the interval,
# or a multiple of the interval plus the offset. So,
# recompute the range in light of the tick size:
my $min_Tick = _adjusted_position($min, $order_of_magnitude, $N_ticks_per_order, 1);
my $max_Tick = _adjusted_position($max, $order_of_magnitude, $N_ticks_per_order, -1);
# Somewhat approximate, but hopefully it'll work right:
my $N_Ticks = $range / $order_of_magnitude * $N_ticks_per_order;
# Obviously, max tick and min tick must not overlap:
next if $N_Ticks < 2;
# compute the score:
my $score = (abs($N_Ticks - 5) + $handicap)**2;
# If it's the best score, use it:
if ($score < $best_score) {
$best_score = $score;
# Add 0.1 to N_Ticks to avoid rounding dilemas:
$best_min_Tick = $min_Tick;
$best_max_Tick = $max_Tick;
$best_N_ticks_per_order = $N_ticks_per_order;
}
}
# Construct the major and minor tick marks:
my @Ticks;
my @ticks;
my $current_value = $best_min_Tick;
if ($best_N_ticks_per_order == 3) {
}
elsif ($best_N_ticks_per_order == 2) {
}
elsif ($best_N_ticks_per_order == 1) {
}
elsif ($best_N_ticks_per_order == 0.5) {
}
$ticks = pdl(@ticks);
$Ticks = pdl(@Ticks);
print "Ticks are ", 10**$best_Ticks, "\n"; return ($best_Ticks, $ticks); return (10**$best_Ticks, 10**$ticks);
AUTHOR
David Mertens (dcmertens.perl@gmail.com)
SEE ALSO
This is a component of PDL::Graphics::Prima. This library is composed of many modules, including:
- PDL::Graphics::Prima
-
Defines the Plot widget for use in Prima applications
- PDL::Graphics::Prima::Axis
-
Specifies the behavior of axes (but not the scaling)
- PDL::Graphics::Prima::DataSet
-
Specifies the behavior of DataSets
- PDL::Graphics::Prima::Internals
-
A dumping ground for my partial documentation of some of the more complicated stuff. It's not organized, so you probably shouldn't read it.
- PDL::Graphics::Prima::Limits
-
Defines the lm:: namespace
- PDL::Graphics::Prima::Palette
-
Specifies a collection of different color palettes
- PDL::Graphics::Prima::PlotType
-
Defines the different ways to visualize your data
- PDL::Graphics::Prima::Scaling
-
Specifies different kinds of scaling, including linear and logarithmic
- PDL::Graphics::Prima::Simple
-
Defines a number of useful functions for generating simple and not-so-simple plots
LICENSE AND COPYRIGHT
Portions of this module's code are copyright (c) 2011 The Board of Trustees at the University of Illinois.
Portions of this module's code are copyright (c) 2011-2012 Northwestern University.
This module's documentation are copyright (c) 2011-2012 David Mertens.
All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.