I try to make a basic structure file in r markdown where I can show 2 images. How can I bring the caption with transperancy into the image. And can someone give me a tip how to present a r markdown code as a question? The 3 backticks are working until the next ``` ..., and this is a problem with bunch of code junks. Thank you.
output:
desired output:
code:
---
title: "test"
author: "TJ"
date: "7 1 2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
## R Markdown
![](output.png)
## desired Output with caption in images
![](desired_output.png)
You can use image_read
and image_annotate
from the package magick
. Here is an example:
library(magick)
yoda <-image_read(path = "yoda.jpg")
image_annotate(
yoda,
"Figure 1A",
size = 30,
color = "white",
boxcolor = adjustcolor("black", alpha = 0.2), #change the alpha value for more of less transparency
gravity = "southwest"
)
If you want to specify the location of the caption you can replace gravity = "southwest"
with with location = " your cordinates"
. Ex:
image_annotate(
yoda,
"Figure 1A",
size = 30,
color = "white",
boxcolor = adjustcolor("black", alpha = 0.2), #change the alpha value for more of less transparency
location = "+10+400"
)
More about the magick package here.
About the second question about write Markdown as code in the text:
Select the text you want as a code and press tab
twice: