【发布时间】:2019-03-26 14:27:19
【问题描述】:
我需要绘制一段时间内发现的紫罗兰标本的数量。在图例中,我想显示 2 个观察到的物种以及它们的总和。为了写出科学的正确性,我还需要“中提琴规格之和”中的“中提琴”斜体。
我想和theforestecologist 在他的顶级传奇中实际上相同,但我无法用文字重现他的例子。所以我使用text.font() 以一种简单的方式做到了这一点,但整行都是斜体。我在main() 中使用的代码缩写没有帮助。
是否可以在图例中只写一部分斜体?
vr <- sample(1:100, 10, replace = TRUE)
vo <- sample(1:100, 10, replace = TRUE)
date <- Sys.Date() + sort(sample(1:10, 10))
vs <- vr + vo
df <- data.frame(vr, vo, date, vs)
plot(
vs ~ date,
data = df,
type = "o",
ylim = c(0, max(df$vs)),
col = "black",
pch = 13,
cex = 1.2,
lwd = 2,
main = expression(paste(italic('Viola'), " spec. [ind]")),
ylab = "Amount"
)
lines(
vr ~ date,
data = df,
type = "o",
col = "RoyalBlue2",
pch = 1,
cex = 1.2
)
lines(
vo ~ date,
data = df,
type = "o",
col = "springgreen3",
pch = 4,
cex = 1.2
)
legend(
"topright",
inset = c(0.01 , 0.02),
c("Sum of Viola spec.", "Viola odorata", "Viola reichenbachiana"),
xpd = TRUE,
pch = c(13, 1, 4),
pt.cex = 1.2,
col = c(1, "RoyalBlue2", "springgreen3"),
cex = .9,
y.intersp = .9,
bty = "l",
bg = rgb(244, 248, 249, max = 255),
text.font = c(1, 3, 3)
)
【问题讨论】:
标签: r