Multiple y-labels but not multiple y-axes

84 views
Skip to first unread message

Sam Albers

unread,
Feb 7, 2011, 12:59:13 PM2/7/11
to ggplot2
Hello all,

I am would like to produce a figure that was two y-axes labels on either side of the plot. These aren't different y-axes and I won't be drawing multiple sets of data on one figure by making use of two axes. I am aware of the pitfalls of this. Rather, I would like to print a label on the right side of the plot simply as a secondary label - an additional piece of information. In the example below I have the label of the left side (y) and i would like to use the values from y2 to label the other side. The y and y2 values represent the same thing and thus should be aligned accordingly. Is this possible in ggplot2?

Thanks in advance.

Sam

library(ggplot2)
x <-runif(80, 0,100)
data <- as.data.frame(x)
data$y <-1:4
data$y2 <- factor(c("One","Two","Three","Four"))
data$z <- factor(c("A","B","C","D","E"))

a <- ggplot(data, aes(x = y, y = x, fill = z))
    
b <- a + geom_bar(stat = "identity", position = "stack") + coord_flip()
b

--
*****************************************************
Sam Albers
Geography Program
University of Northern British Columbia
3333 University Way
Prince George, British Columbia
Canada, V2N 4Z9
phone: 250 960-6777
*****************************************************

Brian

unread,
Feb 7, 2011, 2:07:14 PM2/7/11
to ggp...@googlegroups.com
Sam,

This is essentially a version of my question: https://groups.google.com/d/topic/ggplot2/R_OoBTjDuEE/discussion


I'm not sure that we've gotten satisfactory answers yet.

- Brian
Reply all
Reply to author
Forward
0 new messages