Skip to content
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
4 changes: 3 additions & 1 deletion lib/Plots/Plot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ sub new {
axes => Plots::Axes->new,
colors => {},
data => [],
texPackages => [],
tikzLibraries => []
}, $class;

# Besides for these core options, pass everything else to the Axes object.
for ('width', 'height', 'tex_size', 'rounded_corners') {
for ('width', 'height', 'tex_size', 'rounded_corners', 'texPackages', 'tikzLibraries') {
$self->{$_} = delete $options{$_} if $options{$_};
}
$self->axes->set(%options) if %options;
Expand Down
7 changes: 5 additions & 2 deletions lib/Plots/Tikz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ sub new {
$image->svgMethod(eval('$main::envir{latexImageSVGMethod}') // 'dvisvgm');
$image->convertOptions(eval('$main::envir{latexImageConvertOptions}') // { input => {}, output => {} });
$image->ext($plots->ext);
$image->tikzLibraries('arrows.meta,plotmarks,calc,spath3');
$image->texPackages(['pgfplots']);
$image->texPackages([ 'amsmath', 'pgfplots', @{ $plots->{texPackages} } ]);

my $tikzLibraries = 'arrows.meta,plotmarks,calc,spath3';
$tikzLibraries .= ',' . join(',', @{ $plots->{tikzLibraries} }) if @{ $plots->{tikzLibraries} };
$image->tikzLibraries($tikzLibraries);

# Set the pgfplots compatibility, add the pgfplots fillbetween library, define a save
# box that is used to wrap the axes in a nice rectangle frame with a white background, and redefine
Expand Down
13 changes: 13 additions & 0 deletions macros/graph/plots.pl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ =head1 USAGE
be used. Note that this may not work well for images that have elements of the
plot near or in the corners.

=item texPackages

This is an array reference of additional TeX packages to use when generating the
TikZ output. By default this includes "amsmath" and "pgfplots". This is useful
for adding packages for labels such as "cancel". See L<PGtikz.pl> for details
on loading packages and options.

=item tikzLibraries

This is an array reference of additional TikZ libraries to include when generating
the TikZ output. By default this includes "arrows.meta", "plotmarks", "calc",
and "splath3".

=back

Add a function and other objects to the plot.
Expand Down
Loading