Skip to content

Commit

Permalink
Updated documentation, moved catdat into internal package data, elimi…
Browse files Browse the repository at this point in the history
…nated errors and reduced warnings from devtools::check()
  • Loading branch information
calpan committed Feb 10, 2018
1 parent 8b16f3f commit e6fdb1e
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 50 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Expand Up @@ -6,10 +6,11 @@ Date: 2016-03-07
Author: David Gibbs
Maintainer: David Gibbs <dgibbs@systemsbiology.org>
Depends: R (>= 3.1.0)
Imports: png
Imports: png, graphics, utils, grDevices, stats
Suggests:
Description: You can make plots with cats!
License: Apache2.0 + file LICENSE
LazyData: false
LazyData: true
Encoding: UTF-8
URL: https://github.com/Gibbsdavidl/CatterPlots
RoxygenNote: 6.0.1
8 changes: 7 additions & 1 deletion NAMESPACE
@@ -1,6 +1,12 @@
# Generated by roxygen2: do not edit by hand

export(catplot)
export(cats)
export(multicat)
export(morecats)
export(multicat)
export(rainbowCats)
import(grDevices)
import(graphics)
import(png)
import(stats)
import(utils)
2 changes: 0 additions & 2 deletions R/cat_loader.R
Expand Up @@ -22,8 +22,6 @@

# make sure the cats have transparent backgrounds!

library(png)

createCatList <- function(dir) {
fs <- list.files(dir, pattern="png")
catlist <- vector("list", length(fs))
Expand Down
8 changes: 1 addition & 7 deletions R/cat_plot.R
Expand Up @@ -28,6 +28,7 @@
#' @param linecolor color of plotted lines
#' @param type the type of plot ... justcats, or line
#' @param canvas the plotting area
#' @param ... additional parameters to pass to plot()
#'
#' @return a cat plot object... to plot more cats.
#' @examples
Expand All @@ -41,17 +42,13 @@ catplot <- function(xs, ys,
catcolor = '#000000FF',
linecolor=1, type="justcats",
canvas=c(0,1.1,0,1.1), ...) {
require(png)
data(cats)

args <- list(...)

plot(x=xs, y=ys, col=0, xaxt="n", yaxt="n", ...)
par(usr=canvas)

img <- catdat[[cat]]
dims<-dim(img)[1:2] #number of x-y pixels for the img (aspect ratio)
AR<-dims[1]/dims[2]

scaledData <- scaleData(xs,ys,args)
xscale <- scaledData$xscale
Expand Down Expand Up @@ -101,10 +98,7 @@ cats <- function(obj=NULL, xs, ys, size=0.1, cat=1, catcolor = '#000000FF',
print("Please feed the cats! cat_food <- catplot(...); cats(cat_food, ...)")
}


img <- catdat[[cat]]
dims<-dim(img)[1:2] #number of x-y pixels for the img (aspect ratio)
AR<-dims[1]/dims[2]

scaledData <- catsScaleData(obj,xs,ys)
xscale <- scaledData$xscale
Expand Down
22 changes: 12 additions & 10 deletions R/multi_cat.R
Expand Up @@ -19,6 +19,11 @@

#' Multi-cat! More cats. More colors.
#'
#' @import stats
#' @import png
#' @import grDevices
#' @import graphics
#' @import utils
#' @param xs a vector of numbers
#' @param ys another vector of numbers
#' @param size the size of the cat (0.1 is a good starting point)
Expand All @@ -27,6 +32,7 @@
#' @param linecolor color of plotted lines
#' @param type the type of plot ... justcats, or line
#' @param canvas the plotting area
#' @param ... additional parameters to pass to plot()
#'
#' @return a cat plot object... to plot more cats.
#' @examples
Expand All @@ -40,17 +46,14 @@ multicat <- function(xs, ys,
catcolor = '#000000FF',
linecolor=1, type="justcats",
canvas=c(0,1.1,0,1.1), ...) {
require(png)
data(cats)

args <- list(...)

plot(x=xs, y=ys, col=0, xaxt="n", yaxt="n", ...)
par(usr=canvas)

img <- catdat[[cat[1]]]
dims<-dim(img)[1:2] #number of x-y pixels for the img (aspect ratio)
AR<-dims[1]/dims[2]
#dims<-dim(img)[1:2] #number of x-y pixels for the img (aspect ratio)
#AR<-dims[1]/dims[2]

scaledData <- scaleData(xs,ys,args)
xscale <- scaledData$xscale
Expand All @@ -71,7 +74,7 @@ multicat <- function(xs, ys,
catcolors <- rep_len(catcolor, length(xscale))

# color the images
imgs = mapply(colorMod, catdat[cats], catcolors, SIMPLIFY = F)
imgs = mapply(colorMod, catdat[cats], catcolors, SIMPLIFY = FALSE)

# draw them
invisible(mapply(rasterImage, imgs, xscale - size/2, yscale - size/2, xscale + size/2, yscale + size/2))
Expand Down Expand Up @@ -121,6 +124,7 @@ multipoint <- function(xs, ys,
#' @param type the type of plot ... justcats, or line
#' @param yshift shifts the cat up or down, within the scaled space
#' @param xshift shifts the cat left or right, within the scaled space.
#' @param color whether or not to apply color to image(s)
#'
#' @return a cat plot object... to plot more cats.
#' @examples
Expand All @@ -130,15 +134,13 @@ multipoint <- function(xs, ys,
#' cats(purr, -x, -y, cat=4, catcolor=c(1,0,1,1))'
#' @export
morecats <- function(obj=NULL, xs, ys, size=0.1, cat=c(4,5,6), catcolor = c('#0000FFFF', '#00FF00FF'),
linecolor=1, type="justcats", yshift=0, xshift=0, color=T) {
linecolor=1, type="justcats", yshift=0, xshift=0, color=TRUE) {
# needs a plot already up, and the catObj returned from it.
if(is.null(obj)) {
print("Please feed the cats! cat_food <- catplot(...); cats(cat_food, ...)")
}

img <- catdat[[cat[1]]]
dims<-dim(img)[1:2] #number of x-y pixels for the img (aspect ratio)
AR<-dims[1]/dims[2]

scaledData <- catsScaleData(obj,xs,ys)
xscale <- scaledData$xscale + xshift
Expand All @@ -154,7 +156,7 @@ morecats <- function(obj=NULL, xs, ys, size=0.1, cat=c(4,5,6), catcolor = c('#00

# color the images
if (color){
imgs = mapply(colorMod, catdat[cats], catcolors, SIMPLIFY = F)
imgs = mapply(colorMod, catdat[cats], catcolors, SIMPLIFY = FALSE)
} else {
imgs = catdat[cats]
}
Expand Down
21 changes: 9 additions & 12 deletions R/rainbow_cats.R
Expand Up @@ -22,26 +22,23 @@
#' @param xs a vector of numbers
#' @param ys another vector of numbers
#' @param ptsize control the size.
#' @param yspread. the vertical spread of the rainbow
#' @param xspread. the horizontal spread of rainbow particles
#' @param cat. what cat shall make thine rainbow? nyan is 11
#' @param catshiftx. get your cat connected to the rainbow!
#' @param catshifty. get your cat connected to the rainbow!
#' @param canvas. you are probably going to want to zoom in and out (x1,x2,y1,y2)
#' @param spar. the smoothness of the rainbow.
#' @param yspread the vertical spread of the rainbow
#' @param xspread the horizontal spread of rainbow particles
#' @param cat what cat shall make thine rainbow? nyan is 11
#' @param catshiftx get your cat connected to the rainbow!
#' @param catshifty get your cat connected to the rainbow!
#' @param canvas you are probably going to want to zoom in and out (x1,x2,y1,y2)
#' @param spar the smoothness of the rainbow.
#'
#' @return a rainbow!
#' @examples
#' see also tests/rainbow_test.R
# see also tests/rainbow_test.R
#' x <- -10:10
#' y <- -x^2 + 10
#' rainbowCats(x, y, yspread=0.05, xspread=0.05, canvas=c(-0.5,1.5,-1,0.8))
#' @export
rainbowCats <- function(xs, ys, ptsize=0.1, yspread=0.1, xspread=0.1,
cat=11, catshiftx=0, catshifty=0, spar=NA, canvas=c(-0.5,1.5,-1,1.5)) {
require(png)
data(cats)

if (is.na(spar)) {
sm <- smooth.spline(ys~xs)
} else {
Expand All @@ -63,5 +60,5 @@ rainbowCats <- function(xs, ys, ptsize=0.1, yspread=0.1, xspread=0.1,

print(paste(z$x[length(z$x)], " ", z$y[length(z$y)], "\n\n"))
morecats(cp, xs=z$x[length(z$x)], ys=z$y[length(z$y)],
xshift=catshiftx, yshift=catshifty, size=1, cat=cat, color=F)
xshift=catshiftx, yshift=catshifty, size=1, cat=cat, color=FALSE)
}
Binary file added R/sysdata.rda
Binary file not shown.
5 changes: 2 additions & 3 deletions R/zzz.R
Expand Up @@ -17,7 +17,6 @@
# limitations under the License.
#

.onLoad <- function(libname = find.package("CatterPlot"), pkgname = "CatterPlot") {
require(png)
packageStartupMessage("\nWelcome to CatterPlot.\n")
.onAttach <- function(libname = find.package("CatterPlots"), pkgname = "CatterPlots") {
packageStartupMessage("\nWelcome to CatterPlots.\n")
}
Binary file removed data/cats.rda
Binary file not shown.
4 changes: 3 additions & 1 deletion man/catplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/cats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/morecats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/multicat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions man/rainbowCats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e6fdb1e

Please sign in to comment.