Moving y-axis labels to right of graph

760 views
Skip to first unread message

Keaven Anderson

unread,
Mar 14, 2012, 1:50:52 PM3/14/12
to ggplot2
I would like to move the y-axis labeling to the right side of the
following graph...for reasons that I hope are apparent.


library(ggplot2)
hr <- c(1/3,1/2,2/3,4/5)
hr <- sort(c(hr,1,1/hr))
nhr<- length(hr)
x <- data.frame(cbind(
Biomarker=c(array(0,nhr),array(1,nhr)),
HR = c(array(1,nhr),hr),
grp = c(1:nhr,1:nhr)))
y <- x[order(grp),]
qplot(data=y,x=Biomarker,y=HR,group=factor(grp),geom="line",log="y")

Dennis Murphy

unread,
Mar 14, 2012, 6:04:19 PM3/14/12
to Keaven Anderson, ggplot2
Hi:

This isn't the most elegant look I can think of, but it may be enough
to get you started:

qplot(data=y,x=Biomarker,y=HR,group=factor(grp),geom="line",log="y") +
geom_text(data = subset(y, Biomarker == 1L),
aes(label = grp), x = 1.1, size = 5) +
scale_x_continuous(breaks = c(0, 1), limits = c(0, 1.1))

Dennis

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Jean-Olivier Irisson

unread,
Mar 15, 2012, 5:46:29 AM3/15/12
to Keaven Anderson, ggplot2

Kohske developed this in his own branch of the ggplot2 code:
https://github.com/kohske/ggplot2/tree/feature/pguide

You can look at the thread on the devel mailing list:
http://groups.google.com/group/ggplot2-dev/browse_thread/thread/264254e422c1910c

Using the package devtools you should be able to install this quite easily (function install_github())

Jean-Olivier Irisson
---
Observatoire Océanologique
Station Zoologique, B.P. 28, Chemin du Lazaret
06230 Villefranche-sur-Mer
Tel: +33 04 93 76 38 04
Mob: +33 06 21 05 19 90
http://jo.irisson.com/

Reply all
Reply to author
Forward
0 new messages