Skip to content

Commit

Permalink
Add S3 methods for lines.xts and points.xts
Browse files Browse the repository at this point in the history
s/addPoints/points.xts

git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/xts/pkg/xts@869 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
  • Loading branch information
rossb34 committed Jan 10, 2015
1 parent 904463e commit 146e614
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ export(axTicksByTime)
export(plot.xts)
export(addLegend)
export(addEventLines)
export(addPoints)
# export(addPoints)
export(addSeries)
S3method(plot,xts)
S3method(lines,xts)
S3method(points,xts)
S3method(print, replot_xts)
S3method(plot, replot_xts)

Expand Down
13 changes: 11 additions & 2 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,15 @@ addSeries <- function(x, main="", on=NA, type="l", col=NULL, lty=1, lwd=1, pch=0
plot_object
}

lines.xts <- function(x, ..., main="", on=NA, col=NULL, lty=1, lwd=1, pch=0){
addSeries(x, ...=..., main=main, on=on, type="l", col=col, lty=lty, lwd=lwd, pch=pch)
}


# addPoints <- function(x, main="", on=NA, col=NULL, pch=0, ...){
# addSeries(x, main=main, on=on, type="p", col=col, pch=pch, ...)
# }

#' Add time series of points to an existing xts plot
#'
#' @param x an xts object to plot.
Expand All @@ -874,8 +883,8 @@ addSeries <- function(x, main="", on=NA, type="l", col=NULL, lty=1, lwd=1, pch=0
#' @param pch the type of plot to be drawn, same as in \code{\link{plot}}.
#' @param \dots any other passthrough parameters. Not currently used.
#' @author Ross Bennett
addPoints <- function(x, main="", on=NA, col=NULL, pch=0, ...){
addSeries(x, main=main, on=on, type="p", col=col, pch=pch, ...)
points.xts <- function(x, ..., main="", on=NA, col=NULL, pch=0){
addSeries(x, ...=..., main=main, on=on, type="p", col=col, pch=pch)
}

#' Add vertical lines to an existing xts plot
Expand Down
30 changes: 30 additions & 0 deletions man/lines.xts.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
\name{lines.xts}
\alias{lines.xts}
\title{Add time series lines to an existing xts plot}
\usage{
\method{lines}{xts}(x, ..., main = "", on = NA, col = NULL, lty = 1,
lwd = 1, pch = 0)
}
\arguments{
\item{x}{an xts object to plot.}

\item{\dots}{any other passthrough parameters. Not currently used.}

\item{main}{main title for a new panel if drawn.}

\item{on}{panel number to draw on. A new panel will be drawn if \code{on=NA}.}

\item{col}{color palette to use, set by default to rational choices.}

\item{lty}{set the line type, same as in \code{\link{plot}}.}

\item{lwd}{set the line width, same as in \code{\link{plot}}.}

\item{pch}{the type of plot to be drawn, same as in \code{\link{plot}}.}
}
\description{
Add time series lines to an existing xts plot
}
\author{
Ross Bennett
}
11 changes: 5 additions & 6 deletions man/addPoints.Rd → man/points.xts.Rd
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
\name{addPoints}
\alias{addPoints}
\name{points.xts}
\alias{points.xts}
\title{Add time series of points to an existing xts plot}
\usage{
addPoints(x, main = "", on = NA, col = NULL, pch = 0, ...)
\method{points}{xts}(x, ..., main = "", on = NA, col = NULL, pch = 0)
}
\arguments{
\item{x}{an xts object to plot.}

\item{\dots}{any other passthrough parameters. Not currently used.}

\item{main}{main title for a new panel if drawn.}

\item{on}{panel number to draw on. A new panel will be drawn if \code{on=NA}.}

\item{col}{color palette to use, set by default to rational choices.}

\item{pch}{the type of plot to be drawn, same as in \code{\link{plot}}.}

\item{\dots}{any other passthrough parameters. Not currently used.}
}
\description{
Add time series of points to an existing xts plot
Expand Down

0 comments on commit 146e614

Please sign in to comment.