ltxsparklines-package: Lightweight Sparklines for a LaTeX Document

ltxsparklines-packageR Documentation

Lightweight Sparklines for a LaTeX Document

Description

Sparklines are small plots (about one line of text high), made popular by Edward Tufte. This package is the interface from R to the LaTeX package sparklines by Andreas Loeffer and Dan Luecking (<http://www.ctan.org/pkg/sparklines>). It can work with Sweave or knitr or other engines that produce TeX. The package can be used to plot vectors, matrices, data frames, time series (in ts or zoo format).

Details

The DESCRIPTION file: This package was not yet installed at build time.
Index: This package was not yet installed at build time.

There are several packages that produce sparklines in R: SparkTable by Alexander Kowarik, Bernhard Meindl, Matthias Templ (https://CRAN.R-project.org/package=sparkTable), sparklines by Bart (https://github.com/Bart6114/sparklines). However, they either provide HTML-only output, or require Java libraries. This is a lightweight and easy to use package for LaTeX users.

The package provides one function, sparkline, which outputs LaTeX code compatible with LaTeX package sparklines (Andreas Loeffer and Dan Luecking, http://www.ctan.org/pkg/sparklines).

Package options and setup

Do not forget to add \usepackage{sparklines} to the preamble of your TeX document.

There are two sets of options for sparklines in LaTeX: those which are set from TeX, and those which are set from R. The TeX options should be set with \renewcommand, \definecolor or \setlength, for example,

    % The height of the sparklines in ex units
    \renewcommand\sparklineheight{1.75} 
    % The line width
    \setlength\sparklinethickness{0.4pt}
    % The color of the sparkline
    \definecolor{sparklinecolor}{named}{blue}
    % The color of the sparkine rectangle when present
    \definecolor{sparkrectanglecolor}{gray}{0.8}
    % The dot width
    \setlength\sparkdotwidth{2pt}
    % The color of the spikes
    \definecolor{sparkspikecolor}{named}{red}
    % The color of the bottom line when present
    \definecolor{bottomlinecolor}{gray}{0.2}
    % The thickness of the bottom line
    \setlength\sparkbottomlinethickness{.2pt}
    % The clipping separation (need sparklines v1.7 or later)
    \setlength\sparklineclipsep{2pt}    
    

See the documentation for the LaTeX sparklines package.

Most options set from R define the defaults for sparkline command. They can be overriden by the corresponding argument of sparkline, for example, sparkline(...,width=20).

ltxsparklines.width

The width of the sparkline (10).

ltxsparklines.clip

Whether to clip the sparklines in the drawing region (FALSE). You need LaTeX sparklines package at least v1.7 for clip=TRUE.

ltxsparklines.na.rm

Whether to delete NA lines from the sparkline data (TRUE).

ltxsparklines.bottomline

Whether to add the bottom line (FALSE). You need LaTeX sparklines package at least v1.6 to draw bottom line.

ltxsparklines.bottomlinex

The dimensions of the extended bottom line (by default c(NA, NA), which means no extended bottom line). You need LaTeX sparklines package at least v1.7 to draw extended bottom line.

ltxsparklines.startdotcolor

The color of the dot at the start of the sparkline. If NA (the default), do not draw the dot.

ltxsparklines.enddotcolor

The color of the dot at the end of the sparkline. If NA (the default), do not draw the dot.

ltxsparklines.dotcolor

The color of dots in the sparkline (blue).

ltxsparklines.output

The output format (knitr).

Author(s)

Boris Veytsman

Maintainer: <borisv@lk.net>

References

Andreas Loeffer and Dan Luecking, Sparklines, 2016, http://www.ctan.org/pkg/sparklines

See Also

sparkline vignette(ltxsparklines)

Examples

## Not run: 
sparkline(x=c(1,3,6),
          y=c(5,8,9),
          startdotcolor='blue',
          enddotcolor='red')

## End(Not run)
## Not run: 
sparkline(Nile)

## End(Not run)

borisveytsman/ltxsparklines documentation built on April 7, 2022, 6 a.m.