在persp()中的xlab ylab和zlab是否与bquote不兼容?

时间:2017-04-19 23:23:15

标签: r plot

我想知道如何在R中bquote xlab,ylab zlab 中使用persp()。具体来说,我正在尝试为 xlab 添加希腊字母mu,为 ylab 添加sigma,为 zlab 添加“Likelihood~(mu, sigma)”没有成功? (允许使用希腊字母的任何替代方案?)

这是我的R代码:

x = seq(-10, 10, len = 30)

y = seq(0, 5, len = 30)

f = function(x, y) { dnorm(2, x, y) }

z <- outer(x, y, f)


persp(x, y, z , theta = 30, phi = 30, expand = 0.5, col = 'lightblue',
  xlab = bquote(mu), ylab = bquote(sigma), zlab = bquote('Likelihood'~(mu)~"," ~ (sigma)) )

1 个答案:

答案 0 :(得分:1)

persp不允许使用表达式。请尝试使用unicode符号

persp(x, y, z , theta = 30, phi = 30, expand = 0.5, col = 'lightblue',
      xlab = "\u03bc",
      ylab = "\u03c3",
      zlab = paste('Likelihood ',"\u03bc", "\u03c3", sep = "") )