Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在names.arg函数中使用表达式_R_Expression_Plotmath - Fatal编程技术网

如何在names.arg函数中使用表达式

如何在names.arg函数中使用表达式,r,expression,plotmath,R,Expression,Plotmath,我的条形图中有几个碳化合物,但我需要为每个化合物的相关数字下标,例如C*12*-C*16*,C*17*-C*25*,C*26*-C*32*,C*33*-C*37* 我正在尝试使用表达式函数,但它与barplot上的names.arg函数不匹配。请参阅目前的代码: barplot(t(as.matrix(alkane)), ylim=c(0,100), names.arg=c("C12-C16","C17-C25","C26-C32","C33-C37"), xlab="Hydroca

我的条形图中有几个碳化合物,但我需要为每个化合物的相关数字下标,例如C*12*-C*16*,C*17*-C*25*,C*26*-C*32*,C*33*-C*37*

我正在尝试使用表达式函数,但它与barplot上的names.arg函数不匹配。请参阅目前的代码:

barplot(t(as.matrix(alkane)),
  ylim=c(0,100),
  names.arg=c("C12-C16","C17-C25","C26-C32","C33-C37"),
  xlab="Hydrocarbons analysed after 21 days",
  ylab="% loss in concentration relative to day 0",
  cex.lab=0.8,
  cex.axis=0.8,
  cex.names=0.8,
  cex.main=0.8,
  beside=TRUE,
  col=c("blue","red"))

非常感谢您的帮助。

您可以通过突出显示看到,您的
名称格式不正确。arg
,请检查要配对的

names.arg=c("C12-C16","C17-C25","C26-C32","C33-C37"),

我想你在找这个:

set.seed(1)
x <- matrix(rbeta(8, 5, 5), 2, 4)

barplot(x, names.arg = 
          expression(C[12]-C[16], C[17]-C[25], C[26]-C[32],C[33]-C[37]))
set.seed(1)

这是在这个网站上输入的一个错误。我仍然想不出一种方法来使用表达式在每个C的数字上引入下标。