Skip to content

Restructire the POD of macros (graph) #1269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: PG-2.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion macros/graph/LiveGraphicsParametricSurface3D.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ =head1 DESCRIPTION
and returns a string of plot data that can be displayed using the C<Live3Ddata>
routine of the L<LiveGraphics3D.pl> macro.

=head1 Methods
=head1 METHODS

=head2 ParametricSurface3D

Expand Down
9 changes: 3 additions & 6 deletions macros/graph/PGanalyzeGraph.pl
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
sub _PGanalyzeGraph_init { }

################################################################
# subroutines
################################################################

=head1 NAME

PGanalyzeGraph.pl
PGanalyzeGraph.pl - These routines support the analysis of graphical input from students.

=head1 DESCRIPTION

Expand All @@ -28,6 +23,8 @@ =head2 detect_intervals

=cut

sub _PGanalyzeGraph_init { }

sub detect_intervals {
my $pointDisplayString = shift;
my @intervals;
Expand Down
7 changes: 2 additions & 5 deletions macros/graph/PGgraphgrid.pl
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
sub _PGgraphgrid_init { }; # don't reload this file

=pod

=head1 NAME

PGgraphgrid.pl
PGgraphgrid.pl - provides functionality for plotting a grid on a graph.

=head1 SYNOPSIS

Expand Down Expand Up @@ -47,7 +44,7 @@ =head1 AUTHORS

=cut

################################################
sub _PGgraphgrid_init { }; # don't reload this file

loadMacros("MathObjects.pl", "PGgraphmacros.pl",);

Expand Down
88 changes: 25 additions & 63 deletions macros/graph/PGgraphmacros.pl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

=head1 NAME

PGgraphmacros -- in courseScripts directory
PGgraphmacros.pl - provides functionality for plotting functions, points and adding labels.

=head1 SYNPOSIS
=head1 SYNOPSIS

use Fun;
use Label;
Expand All @@ -21,68 +21,35 @@ =head1 DESCRIPTION
may require direct access to the underlying modules. If these complicated projects are common
then it may be desirable to create additional macros. (See numericalmacros.pl for one example.)


=cut

=head2 Other constructs

See F<PGbasicmacros> for definitions of C<image> and C<caption>

=cut

#my $User = $main::studentLogin;
#my $psvn = $main::psvn; #$main::in{'probSetKey'}; #in{'probSetNumber'}; #$main::probSetNumber;
#my $setNumber = $main::setNumber;
#my $probNum = $main::probNum;
=head1 FUNCTIONS

#########################################################
# this initializes a graph object
#########################################################
# graphObject = init_graph(xmin,ymin,xmax,ymax,options)
# options include 'grid' =>[8,8] or
# 'ticks'=>[8,8] and/or
# 'axes'
#########################################################
=head2 init_graph

#loadMacros("MathObjects.pl"); # avoid loading the entire package
# of MathObjects since that can mess up
# problems that don't use MathObjects but use Matrices.

=head2 init_graph
$graphObject = init_graph(xmin,ymin,xmax,ymax,'ticks'=>[4,4],'axes'=>[0,0])

=pod
options are

$graphObject = init_graph(xmin,ymin,xmax,ymax,'ticks'=>[4,4],'axes'=>[0,0])
options are
'grid' =>[8,8] or
# there are 8 evenly spaced lines intersecting the horizontal axis
'ticks'=>[8,8] and/or
# there are 8 ticks on the horizontal axis, 8 on the vertical
'axes' => [0,0]
# axes pass through the point (0,0) in real coordinates
'size' => [200,200]
# dimensions of the graph in pixels.
'pixels' =>[200,200] # synonym for size
'grid' =>[8,8] or
# there are 8 evenly spaced lines intersecting the horizontal axis
'ticks'=>[8,8] and/or
# there are 8 ticks on the horizontal axis, 8 on the vertical
'axes' => [0,0]
# axes pass through the point (0,0) in real coordinates
'size' => [200,200]
# dimensions of the graph in pixels.
'pixels' =>[200,200] # synonym for size

Creates a graph object with the default size 200 by 200 pixels.
If you want axes or grids you need to specify them in options. But the default values can be selected for you.


=cut

BEGIN { strict->import; }

sub _PGgraphmacros_init {

}
#sub _PGgraphmacros_export {
#
# my @EXPORT = (
# '&init_graph', '&add_functions', '&plot_functions', '&open_circle',
# '&closed_circle', '&my_math_constants', '&string_to_sub',
# );
# @EXPORT;
#}
sub _PGgraphmacros_init { }

sub init_graph {
my ($xmin, $ymin, $xmax, $ymax, %options) = @_;
Expand Down Expand Up @@ -281,9 +248,7 @@ sub init_graph_no_labels {
$graphRef;
}

=head2 plot_functions

=pod
=head2 plot_functions

Usage: ($f1, $f2, $f3) = plot_functions($graph, $f1, $f2, $f3);
Synonym: add_functions($graph,$f1,$f2,$f3);
Expand Down Expand Up @@ -397,7 +362,8 @@ =head2 insertGraph

TEXT(image(insertGraph($graph)) );

where C<image> takes care of creating the proper URL for accessing the graph and for creating the HTML code to display the image.
where C<image> takes care of creating the proper URL for accessing the graph and for
creating the HTML code to display the image.

Another common usage is:

Expand Down Expand Up @@ -425,7 +391,6 @@ =head2 'Circle' lables

=cut

#########################################################
sub open_circle {
my ($cx, $cy, $color) = @_;
new Circle($cx, $cy, 4, $color, 'nearwhite');
Expand All @@ -437,16 +402,15 @@ sub closed_circle {
new Circle($cx, $cy, 4, $color, $color);
}

=head2 Auxiliary macros

=head3 string_to_sub and my_math_constants
=head2 string_to_sub

=head2 my_math_constants

These are internal macros which govern the interpretation of equations.

Usage: C<$string = my_math_constants($string)>

Usage: $string = my_math_constants($string)
$subroutine_reference = my_string_to_sub($string)
$subroutine_reference = string_to_sub($string)

C<my_math_constants>
interprets pi, e as mathematical constants 3.1415926... and 2.71828... respectively. (Case is important).
Expand Down Expand Up @@ -491,8 +455,8 @@ sub string_to_sub {
my ($subRef, $PG_eval_errors, $PG_full_error_report) =
PG_restricted_eval(" sub { my \$XVAR = shift; my \$out = $in; \$out; } ");
if ($PG_eval_errors) {
die
" ERROR while defining a function from the string:\n\n$main::BR $main::BR $str_in $main::BR $main::BR\n\n $PG_eval_errors";
die " ERROR while defining a function from the string:\n\n$main::BR $main::BR "
. "$str_in $main::BR $main::BR\n\n $PG_eval_errors";
} else {
$out = $subRef;
}
Expand All @@ -501,6 +465,4 @@ sub string_to_sub {
$out;
}

#########################################################

1;
2 changes: 0 additions & 2 deletions macros/graph/PGlateximage.pl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ =head1 DESCRIPTION

image(insertGraph($image));

=head1 DETAILED USAGE

There are several LaTeXImage parameters that may need to be set for the
LaTeXImage object return by createLaTeXImage to generate the desired image.

Expand Down
28 changes: 19 additions & 9 deletions macros/graph/PGstatisticsGraphMacros.pl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#require 'PGstatisticsmacros.pl';

=head1 NAME

PGstatisticsGraphMacros -- in courseScripts directory
PGstatisticsGraphMacros.pl - Provides statistic graphs using the WWPlot macros.

=head1 SYNPOSIS
=head1 SYNOPSIS

use Fun;
use Label;
Expand All @@ -24,10 +23,7 @@ =head1 DESCRIPTION
common then it may be desirable to create additional macros. (See
numericalmacros.pl for one example.)


=cut

=head2 Other constructs
=head2 SEE ALSO

See F<PGbasicmacros> for definitions of C<image> and C<caption>

Expand Down Expand Up @@ -85,6 +81,10 @@ sub push_stat_data_set {
push(@accumulatedDataSets, $data);
}

=head2 init_statistics_graph

=cut

sub init_statistics_graph {
my (%options) = @_;
my $numberDataSets = 1 + $#accumulatedDataSets;
Expand Down Expand Up @@ -118,6 +118,10 @@ sub init_statistics_graph {
$graphRef;
}

=head2 getMinMax

=cut

sub getMinMax {
# Routine to return the smallest and largest value in the list of
# numbers given for the arguments to the function.
Expand All @@ -131,6 +135,10 @@ sub getMinMax {
($xmin, $xmax);
}

=head2 add_boxplot

=cut

sub add_boxplot {
# add_boxplot($graphRef,{"outliers"=>1});
#
Expand Down Expand Up @@ -232,6 +240,10 @@ sub add_boxplot {
$bounds;
}

=head2 add_histogram

=cut

sub add_histogram {
my $graphRef = shift;
my $numberBins = shift;
Expand Down Expand Up @@ -338,6 +350,4 @@ sub add_histogram {
$bounds;
}

#########################################################

1;
2 changes: 0 additions & 2 deletions macros/graph/PGtikz.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ =head1 DESCRIPTION

image(insertGraph($image));

=head1 DETAILED USAGE

There are several LaTeXImage parameters that may need to be set for the
LaTeXImage object return by createTikZImage to generate the desired image.

Expand Down
20 changes: 8 additions & 12 deletions macros/graph/imageChoice.pl
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
loadMacros('PGchoicemacros.pl', 'unionUtils.pl', 'choiceUtils.pl',);

loadMacros('PGchoicemacros.pl', 'unionUtils.pl', 'choiceUtils.pl');

sub _imageChoice_init { }; # don't reload this file

######################################################################
#
# Create a match list where the answers are images
#

# Usage: $ml = new_image_match_list(options);
#

# where options are those that can be supplied to image_print_a below.
# The answers should be an image name or reference to a plot object
# (or a reference to a pair of either of these), and they are passed
# to the Image function for processing. See unionUtils.pl for more
# information on how these are handled.
#

sub new_image_match_list {
my $ml = new Match(random(1, 2000, 1), \&alt_print_q, \&img_print_a);
$ml->{ImageOptions} = [@_];
$ml;
}

######################################################################
#
# A print routine for image matching. This is designed to display
# four graphs per row. More can be included by setting the ImageOptions
# variable in the match list. For example:
#

# $ml->{ImageOptions} = [size => [100,100]]
#

# You can include the following options:
#

# size => [w,h] the width and height of the images
# width => n the width of the images (obsolete)
# height => n the height of the images (obsolete)
Expand All @@ -39,7 +36,6 @@ sub new_image_match_list {
# link => 0 or 1 1 to make a link to the original image
# columns => n the number of images in each row (defaults to 4)
# border => n the width of the image border
#

sub img_print_a {
my $self = shift;
Expand Down
5 changes: 4 additions & 1 deletion macros/graph/plotly3D.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ =head1 NAME

plotly3D.pl - Adds Graph3D, an object for creating 3D parametric curves
and 3D parametric surface plots using the plotly JavaScript library.
L<https://plotly.com/javascript/>

=head1 DESCRIPTION

Expand Down Expand Up @@ -315,6 +314,10 @@ =head1 Graph3D OPTIONS

=back

=head1 SEE ALSO

L<https://plotly.com/javascript/>

=cut

sub _plotly3D_init {
Expand Down
2 changes: 1 addition & 1 deletion macros/graph/plots.pl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ =head2 DATASETS
[[0, 0], [4, -1], color => 'red', start_mark => 'arrow'],
);

If needed, the C<< $plot->add_dataset >> method returns the L<Data|/"DATA OBJECT"> object
If needed, the C<< $plot->add_dataset >> method returns the L<DATASETS> object
(or array of Data objects) which can be manipulated directly.

$data = $plot->add_dataset(...);
Expand Down
1 change: 1 addition & 0 deletions macros/graph/unionImage.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

loadMacros("unionMacros.pl");

sub _unionImage_init { }; # don't reload this file
Expand Down