ltxsparklines-package | R Documentation |
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).
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).
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)
.
The width of the sparkline
(10
).
Whether to clip the sparklines in the
drawing region (FALSE
). You need LaTeX sparklines
package at least v1.7 for clip=TRUE
.
Whether to delete NA
lines from
the sparkline data (TRUE
).
Whether to add the bottom line
(FALSE). You need LaTeX
sparklines
package at least v1.6 to draw bottom
line.
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.
The color of the dot at the start
of the sparkline. If NA
(the default), do not draw the dot.
The color of the dot at the end
of the sparkline. If NA
(the default), do not draw the dot.
The color of dots in the sparkline
(blue
).
The output format (knitr
).
Boris Veytsman
Maintainer: <borisv@lk.net>
Andreas Loeffer and Dan Luecking, Sparklines, 2016, http://www.ctan.org/pkg/sparklines
sparkline
vignette(ltxsparklines)
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.