简体   繁体   English

如何将名称列表设为斜体并在 R 中绘制它们?

[英]How can I italicize a list of names and plot them in R?

I can italicize a phrase when plotting text like this: text(1, 2, substitute(paste(italic('Gorilla gorilla gorilla')) , however, I want to send a whole list of names to text but of course the following won't work text(x-coordinates, y-coordinates, substitute(paste(italic('list')) , as it will just plot "list" repeatedly. Is there a work around?在绘制这样的文本时,我可以将短语设为斜体: text(1, 2, substitute(paste(italic('Gorilla gorilla gorilla')) ,但是,我想将整个名称列表发送到 text 但当然以下内容获胜't work text(x-coordinates, y-coordinates, substitute(paste(italic('list')) ,因为它只会重复绘制“列表”。有解决办法吗?

I have tried to italicize text in the list first and make use of loops.我尝试先将列表中的文本设为斜体并使用循环。

We can use bquote here instead of substitute ;我们可以在这里使用bquote而不是substitute in addition to some other differences (I do not know them all), bquote supports .(somevar) replacement.除了一些其他差异(我不知道所有差异)之外, bquote支持.(somevar)替换。

L <- "hello world"
plot(1)
text(1, 1.1, bquote(.(L) * "    " * italic(.(L))))

带有一些斜体的基本图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在R中的同一图中上标和斜体 - How to superscript and italicize in the same plot in R 在R中用斜体标记后缀 - italicize suffix of a plot label in R 如何在我的热图中仅将基因名称斜体(使用 R)? - How to italicize just gene names in my heatmap (using R)? 在 R 中,我如何使用 ggplot 将 label 的一部分斜体显示在相关矩阵的某些图块上 - In R, how can I italicize part of a label that I display on only some tiles of a correlation matrix using ggplot 如何将此列表转换为R中具有相同名称的数据帧? - How can I convert this list to a dataframe with same names in R? 如何将列表中的所有名称更改为 R 中的一个? - How can I change all the names in a list to one in R? 如何从 R 列表中的 dataframe 名称中提取数字? - How can I extract numbers from dataframe names in a list in R? 如何在时间序列上进行循环并将它们全部绘制在 R 中? - how can I make a loop on time series and plot all them together in R? 如何遍历包含 ggplot2 代码的变量以将它们绘制在 R 中的同一图形上? - How can I loop through variables containing ggplot2 code to plot them on the same graph in R? 如何在R的x轴上使用许多名称来制作条形图? - How can I make a bar plot using many names in x axis in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM