-
-
Save bhaskarvk/229cca8dfd067cfbcb3074c85b950abb to your computer and use it in GitHub Desktop.
Need to move Y axis label above Y axis text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OrgSize | n | |
---|---|---|
Large | 32 | |
Very Large | 36 | |
Very Small | 43 | |
Small | 60 | |
Medium | 67 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suppressMessages(library(ggplot2)) | |
suppressMessages(library(ggalt)) | |
# devtools::install_github('hrbrmstr/hrbrthemes') | |
library(hrbrthemes) | |
scale_x_orgsize <- scale_x_discrete(labels=c( | |
'Very Small\n(<250 employees)', | |
'Small\n(251-2,000 employees)', | |
'Medium\n(2,001-10,000 employees)', | |
'Large\n(10,001-50,000 employees)', | |
'Very Large\n(>50,000 employees)')) | |
orgsize <- readr::read_csv('https://gist.github.com/bhaskarvk/229cca8dfd067cfbcb3074c85b950abb/raw/a6dc75e2c9680ee1148edba71b22f39d23cb2f9e/orgs_by_size.csv') | |
ggplot( | |
orgsize, aes(x = OrgSize, y = n)) + | |
geom_lollipop(point.colour = '#000000', point.size = 1) + | |
coord_flip() + | |
labs(list( | |
x = 'Organization Size', y = 'Number of Orgs.', title = NULL)) + | |
scale_x_orgsize + | |
theme_ipsum_rc(grid='X', axis_title_face = 'bold') + | |
theme(axis.title.y = element_text(angle = 0, vjust = 1)) |
Thanks @bhive01 and @thomasp85.
Slightly shorter version from @baptiste (@tpab)
https://gist.github.com/baptiste/c2191c3f8426889efa2352022ae90b85
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Took a while to get everything installed. [Edit, beat to the punch. I didn't get there anyway.]
Firstly, save the plot to something:
Link to gtable explorer by @cpsievert
http://104.131.111.111:3838/ggtree/
gtable editing by @zevross
http://zevross.com/blog/2014/11/20/under-the-hood-of-ggplot2-graphics-in-r/
@thomasp85 suggests moving the axis title up one row.
https://twitter.com/thomasp85/status/832647591703633922