[英]How to bring caption (with transperancy) into an image in r markdown
I try to make a basic structure file in r markdown where I can show 2 images.我尝试在 r markdown 中制作一个基本结构文件,我可以在其中显示 2 张图像。 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?有人可以给我一个提示,如何提出 r markdown 代码作为问题? The 3 backticks are working until the next ```..., and this is a problem with bunch of code junks. 3 个反引号一直有效,直到下一个 ```...,这是一堆代码垃圾的问题。 Thank you.谢谢你。
output: output:
desired output:所需的 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
.您可以使用 package magick
中的image_read
和image_annotate
。 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"
.如果您想指定标题的位置,您可以将gravity = "southwest"
替换为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 .更多关于魔法 package 的信息在这里。
About the second question about write Markdown as code in the text: Select the text you want as a code and press tab
twice:关于将 Markdown 作为文本中的代码的第二个问题: Select 将您想要的文本作为代码并按两次tab
:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.