Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed ggplot.profr to produce meaningful output (i.e. similar to plot.profr) #2

Open
wants to merge 2 commits into from

2 participants

@andrie

Fixed ggplot.profr to produce meaningful output (i.e. similar to plot.profr)

R/output.r
((8 lines not shown))
stop("Please install ggplot2 to use this plotting method")
data$range <- diff(range(data$time))
-
- ggplot(as.data.frame(data)) +
- geom_rect(aes(xmin = start, xmax = end, ymin = level - 0.5, ymax = level + 0.5),
- fill = "grey95", colour = "black", size = 0.5) +
- geom_text(aes(start + range / 60, level, label = f),
- data = subset(data, time > max(time) * minlabel),
- size = 4, angle = angle, hjust = 0) +
- scale_y_continuous("time") +
- scale_x_continuous("level")
+ ggplot(as.data.frame(data), aes(y=level)) +
+ geom_rect(
+ #aes(xmin=(level), xmax=factor(level)+1, ymin=start, ymax=end),
@hadley Owner
hadley added a note

Can you remove the commented lines? Remembering them is git's job ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 11 deletions.
  1. +11 −11 R/output.r
View
22 R/output.r
@@ -42,17 +42,17 @@ plot.profr <- function(x, ..., minlabel = 0.1, angle = 0) {
#' ggplot(nesting_prof)
#' ggplot(reshape_prof)
#' }
-ggplot.profr <- function(data, ..., minlabel = 0.1, angle=0) {
- if (!require("ggplot2", quiet=TRUE))
+ggplot.profr <- function (data, ..., minlabel = 0.1, angle = 0){
+ if (!require("ggplot2", quiet = TRUE))
stop("Please install ggplot2 to use this plotting method")
data$range <- diff(range(data$time))
-
- ggplot(as.data.frame(data)) +
- geom_rect(aes(xmin = start, xmax = end, ymin = level - 0.5, ymax = level + 0.5),
- fill = "grey95", colour = "black", size = 0.5) +
- geom_text(aes(start + range / 60, level, label = f),
- data = subset(data, time > max(time) * minlabel),
- size = 4, angle = angle, hjust = 0) +
- scale_y_continuous("time") +
- scale_x_continuous("level")
+ ggplot(as.data.frame(data), aes(y=level)) +
+ geom_rect(
+ aes(ymin=level-0.5, ymax=level+0.5, xmin=start, xmax=end),
+ fill = "grey95",
+ colour = "black", size = 0.5) +
+ geom_text(aes(label = f, x = start + range/60),
+ data = subset(data, time > max(time) * minlabel), size = 4, angle = angle, vjust=0.5, hjust = 0) +
+ scale_x_continuous("time") +
+ scale_y_continuous("level")
}
Something went wrong with that request. Please try again.