flip boxplot legend after coord_flip

171 views
Skip to first unread message

Dr. Hans Hansen

unread,
Oct 7, 2013, 9:36:11 AM10/7/13
to ggp...@googlegroups.com

Dear ggplot2-users,

i have a plot similar to this:

ggplot(data = NULL, aes(x = 1, y = rnorm(100), col = rnorm(100)<0)) + geom_boxplot() + coord_flip()

and i wonder, whether it is possible to flip the legend-boxplot-symbol as well by 90 degree?

Thanks a lot, Felix

David Guy

unread,
Oct 7, 2013, 9:46:51 AM10/7/13
to Dr. Hans Hansen, ggplot2
Felix.

You could do the following:

ggplot(data = NULL, aes(x = 1, y = rnorm(100), col = rnorm(100)<0)) + geom_boxplot() + coord_flip()+theme(legend.position="bottom")

and you don't have to worry about the order.

David


--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
David Guy, PhD
R Statistical Consulting Inc.
Flemington, NJ USA
 
Office: 908-237-5107
Cell:    917-941-5890
Fax:    908-284-0356
Skype: david.guy1213


David Guy

unread,
Oct 7, 2013, 9:48:44 AM10/7/13
to Dr. Hans Hansen, ggplot2
Felix,

Another way is to control number of columns in legend:

 ggplot(data = NULL, aes(x = 1, y = rnorm(100), col = rnorm(100)>0)) + geom_boxplot() + coord_flip()+guides(col = guide_legend(nrow = 1, byrow = TRUE))

HTH

david


On Mon, Oct 7, 2013 at 9:36 AM, Dr. Hans Hansen <bea...@gmx.de> wrote:

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dr. Hans Hansen

unread,
Oct 7, 2013, 10:19:46 AM10/7/13
to ggp...@googlegroups.com, Dr. Hans Hansen
Thanks for your input, but you get me wrong, unfortunately. i want to flip the little boxplot symbols within the legend.box in a way, that the whiskers point to the left/right instead of top/bottom. :D

David Guy

unread,
Oct 7, 2013, 10:36:13 AM10/7/13
to Dr. Hans Hansen, ggplot2
Got it. But no immediate solution comes to mind.

Sorry,

David


On Mon, Oct 7, 2013 at 10:19 AM, Dr. Hans Hansen <bea...@gmx.de> wrote:
Thanks for your input, but you get me wrong, unfortunately. i want to flip the little boxplot symbols within the legend.box in a way, that the whiskers point to the left/right instead of top/bottom. :D

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages