简体   繁体   English

R:情节中包含计算值和希腊字母的文本

[英]R: Text in plot with calculated values and greek letters

I am trying to paste a text onto a plot. 我正在尝试将文本粘贴到绘图上。 That text should include a value that has previously been caluclated ("sampleconc") and a greek letter ("mu"). 该文本应包含一个预先计算的值(“ sampleconc”)和一个希腊字母(“ mu”)。 Now I understand how to add greek letters to a text and how to include values, but not how to combine both. 现在,我了解了如何在文本中添加希腊字母以及如何包含值,但是不知道如何将两者结合在一起。

Specifically I want this text to appear: 我特别希望此文本出现:

Sample = sampleconc "mu"g/mL 样品=样品浓度“ mu” g / mL

Where sampleconc is a value and "mu" the greek letter. 其中sampleconc是一个值,“ mu”是希腊字母。 I have tried to add the greek letter using expression(paste(...)) and the value using bquote(Sample == .(sampleconc)), but I don't know how to combine the two without getting an error. 我试图使用expression(paste(...))添加希腊字母,并使用bquote(Sample ==。(sampleconc))添加值,但是我不知道如何将两者结合而不会出错。

Thanks in advance! 提前致谢!

Spacing is tricky with bquote . bquote间隔是棘手的。 You can do it like this: 您可以这样做:

a <- 2
plot(1:10, a*(1:10), main = bquote(Sample==.(a)~mu*g/mL))

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM