Marsh,
Your rectangles won't be very tall with ymax=ymin!
(I hope that wasn't the cause of the 5 hours.)
-Peter Ehlers
On 2010-04-04 14:18, Marshall Feldman wrote:
Hi R fans,
As a newbie following the five-hour rule (after hitting my head against
the wall for five hours, post to this list), I am appealing for some
help understanding geom_rect() in ggplot2.
What I want to do is very simple. I want to generate a plot of
rectangles. Each one represents a business cycle. The x-values will be
pairs representing the start and end of each cycle. The y-values
represent the duration of the cycle (in months). In other words, all
rectangles have coordinates (start, duration) and (end, duration).
rr
I've spent hours trying to figure out the documentation and pouring over
Google and RSeek searches and am at an impasse. The documentation refers
to xmin, xmax, ymin, and ymax but doesn't say anything about them. The
only example gives them both as vectors, so I assume they refer to a
sequence of coordinates in which each rectangle's vertices is given by
(xmin[i],ymin[i]), (xmin[i],ymax[i]), (xmax[i],ymax[i]), and
(xmax[i],ymin[i]). But when I try to plot something simple using this
understanding, I get a blank plot.
Here's my code:
df<- data.frame(
xmin = c(1,5),
xmax = c(2,7),
ymin = c(0,3),
ymax = c(2,5)
)
ggplot(df, aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymin)) +
geom_rect(fill="grey80")
Please help me before I Google again! :-)
Thanks.
Marsh Feldman
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Peter Ehlers
University of Calgary
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.