I have a knitr R-chunk where multiple ggplot2s that are arranged to one figure using cowplot and labelled using cowplot labels.
I'd like to reference the individual plots in the figure, i.e. 1A, 1B, 1C, in my text
I've tried the fig.subcap knitr option, but then I get additional labels: (a), (b), (c). I do not want to use (a), (b), (c) but only my cowplot labels, as cowplot labels are easily changed (position, naming, etc.) and arranging subfigures (my individual ggplot2s) with cowplot is easy.
I tried fig.subcap but then I get unwanted labels (a), (b), (c) at positions that I cannot change Chunk-options
```{r figure, fig.cap= 'myFigure', fig.subcap=c('A', 'B', 'C')}
```
I obtain as expected (a) A, (b) B, (c) C below each individual subplot. I want cowplot labels A, B, C at the side of each individual subplot.
I tried to create empty subcap labels
---
title: "t"
author: "a"
date: "d"
site: bookdown::bookdown_site
documentclass: paper
link-citations: yes
output:
bookdown::pdf_book:
extra_dependencies: subfig
---
```{r}
library(ggplot2)
library(cowplot)
g1 = ggplot()+geom_line(aes(x = c(1, 2), y = c(1, 2)))
g2 = ggplot()+geom_line(aes(x = c(1, 2), y = c(1, 2)))
g3 = ggplot()+geom_line(aes(x = c(1, 2), y = c(1, 2)))
cp = plot_grid(g1, g2, g3, nrow = 3, align = "hv", labels = c('A', 'B', 'C'))
```
```{r fi, fig.cap= 'myFigure', fig.subcap=c('', '', '')}
cp
```
and then cross-reference in the text with
\@ref(fig:fi1), \@ref(fig:fi2), \@ref(fig:fi2)
but that does not work as it notices that I only include the one cowplot (cp).
I also tried to include empty plots in addition to the cowplot:
---
title: "t"
author: "a"
date: "d"
site: bookdown::bookdown_site
documentclass: paper
link-citations: yes
output:
bookdown::pdf_book:
extra_dependencies: subfig
---
```{r}
library(ggplot2)
library(cowplot)
g1 = ggplot()+geom_line(aes(x = c(1, 2), y = c(1, 2)))
g2 = ggplot()+geom_line(aes(x = c(1, 2), y = c(1, 2)))
g3 = ggplot()+geom_line(aes(x = c(1, 2), y = c(1, 2)))
cp = plot_grid(g1, g2, g3, nrow = 3, align = "hv", labels = c('A', 'B', 'C'))
```
```{r f, fig.cap= 'myFigure', fig.subcap=c('', '', '')}
cp
plot.new()
plot.new()
```
Then I can use the empty plots as substitutes
for the subfigures in the cowplot and cross-reference
them with \@ref(fig:f1), \@ref(fig:f2),
\@ref(fig:f2).
But the alignment of the cowplot (cp) is not given and I still get an unwanted (a) from subfigure.