Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:jrnold/ggplotJrnold

  • Loading branch information...
commit 0e5f0c316227dac5a3f6bf5b0c3bd0e113816fd1 2 parents 2c629d6 + cb045d8
@jrnold authored
View
22 R/utils.R
@@ -5,12 +5,15 @@
##' @export
##' @param shapes A numeric or character vector of shapes. See
##' \code{\link{par}}.
+##' @param labels Include the plotting character value of the symbol.
##' @seealso \code{\link[scales]{show_col}}, \code{\link{show_linetypes}}
##'
##' @examples
##' library(scales)
##' show_shapes(shape_pal()(5))
-show_shapes <- function(shapes) {
+##' show_shapes(shape_pal()(3), labels=TRUE)
+##'
+show_shapes <- function(shapes, labels=TRUE) {
n <- length(shapes)
ncol <- ceiling(sqrt(n))
nrow <- ceiling(n/ncol)
@@ -21,8 +24,10 @@ show_shapes <- function(shapes) {
type="n", xlab="", ylab="", axes=FALSE)
for (i in seq_len(ncol(shapes))) {
for (j in seq_len(nrow(shapes))) {
- print(c(i, j))
points(i, j, pch=shapes[j, i])
+ if (labels) {
+ text(i, j, shapes[j, i], pos=1, col="gray70")
+ }
}
}
}
@@ -34,19 +39,26 @@ show_shapes <- function(shapes) {
##' @export
##' @param linetypes A character vector of linetypes. See
##' \code{\link{par}}.
+##' @param labels Label each line with its linetype (lty) value.
+##'
##' @seealso \code{\link[scales]{show_col}}, \code{\link{show_linetypes}}
##'
##' @examples
##' library(scales)
-##' show_shapes(linetype_pal()(3))
-show_linetypes <- function(linetypes) {
+##' show_linetypes(linetype_pal()(3))
+##' show_linetypes(linetype_pal()(3), labels=TRUE)
+show_linetypes <- function(linetypes, labels=TRUE) {
n <- length(linetypes)
plot(0, 0, xlim=c(0, 1), ylim=c(n, 1),
type="n", xlab="", ylab="", axes=FALSE)
for (i in seq_along(linetypes)) {
abline(h=i, lty=linetypes[i])
}
- axis(side=2, at=seq_len(n), tick=FALSE, labels=seq_len(n), las=2)
+ if (labels) {
+ axis(side=2, at=seq_len(n), tick=FALSE, labels=linetypes, las=2)
+ } else {
+ axis(side=2, at=seq_len(n), tick=FALSE, labels=seq_len(n), las=2)
+ }
}
## altered from same function from ggplot2
View
8 man/show_linetypes.Rd
@@ -2,18 +2,22 @@
\alias{show_linetypes}
\title{Show linetypes}
\usage{
- show_linetypes(linetypes)
+ show_linetypes(linetypes, labels = TRUE)
}
\arguments{
\item{linetypes}{A character vector of linetypes. See
\code{\link{par}}.}
+
+ \item{labels}{Label each line with its linetype (lty)
+ value.}
}
\description{
A quick and dirty way to show linetypes.
}
\examples{
library(scales)
-show_shapes(linetype_pal()(3))
+show_linetypes(linetype_pal()(3))
+show_linetypes(linetype_pal()(3), labels=TRUE)
}
\seealso{
\code{\link[scales]{show_col}},
View
6 man/show_shapes.Rd
@@ -2,11 +2,14 @@
\alias{show_shapes}
\title{Show shapes}
\usage{
- show_shapes(shapes)
+ show_shapes(shapes, labels = TRUE)
}
\arguments{
\item{shapes}{A numeric or character vector of shapes.
See \code{\link{par}}.}
+
+ \item{labels}{Include the plotting character value of the
+ symbol.}
}
\description{
A quick and dirty way to show shapes.
@@ -14,6 +17,7 @@
\examples{
library(scales)
show_shapes(shape_pal()(5))
+show_shapes(shape_pal()(3), labels=TRUE)
}
\seealso{
\code{\link[scales]{show_col}},
View
5 man/theme_economist.Rd
@@ -2,7 +2,7 @@
\alias{theme_economist}
\title{ggplot color theme based on the Economist}
\usage{
- theme_economist(base_size = 12, base_family = "",
+ theme_economist(base_size = 10, base_family = "",
horizontal = TRUE, dkpanel = FALSE, stata = FALSE)
}
\arguments{
@@ -32,7 +32,8 @@ q + theme_economist(stata=TRUE) + scale_colour_economist(stata=TRUE)
q + theme_economist(dkpanel=TRUE) + scale_colour_economist(stata=TRUE)
## Change axis lines to vertical
(q + theme_economist(horizontal=FALSE)
- + scale_colour_economist() + coord_flip())
+ + scale_colour_economist() + coord_flip()
+ + ggtitle("Diamonds Are Forever"))
}
\seealso{
Other themes: \code{\link{theme_excel2003}},
Please sign in to comment.
Something went wrong with that request. Please try again.