Commit 62a90776 authored by Quentin Read's avatar Quentin Read
Browse files

ggplot tips n trix

parent 68e2427f
# GGPLOT2 tips 'n' tricks
or, stuff I always have to Google.
Maybe this could become another blog post.
## Multiple rows in legend
```
p +
guides(fill=guide_legend(nrow = 2, byrow=FALSE))
```
## Label the facet CATEGORIES themselves
There is no good way to do this in ggplot2 internally. You will need to use cowplot.
This is just an example and it mightn't work exactly as is. The numbers may need tweaking. `plot.margin` is 5.5 points for all margins across the board. The first two arguments are top and right so you make them a bit wider to accommodate the labels.
```
library(cowplot)
p <- p + theme(plot.margin = unit(c(25, 25, 5.5, 5.5), 'points'))
ggdraw(p) +
draw_label('blah', x = 0.5, y = 0.97) +
draw_label('blah', x= 0.99, y= 0.5, angle = -90)
```
\ No newline at end of file
......@@ -9,7 +9,7 @@
# 1 X           â\u0081Ÿã€€X
# Better:
# read.csv.better(file_path, header = FALSE)
# read.csv.better("spcs.csv", header = FALSE)
# V1
# 1 X X
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment