r R绘制#R #plots

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r R绘制#R #plots相关的知识,希望对你有一定的参考价值。

test <- data.frame(var.a = c(372.4070, 302.0429), var.b = c(91.76343, 68.51852))

funProp <- function(testCol) {
  test[, testCol]/max(test[, testCol])
}

test$var.a.prop <- funProp("var.a")
test$var.b.prop <- funProp("var.b")

barplot(t(as.matrix(test[, c("var.a.prop", "var.b.prop")])),  beside = TRUE, yaxt = "n", xlab = "", ylab = "", col = c('black', 'red'), names.arg = c("GO", "NOGO"))

axis(2, at = seq(0, max(test$var.a.prop), length.out = 10), labels = round(seq(0, max(test$var.a), length.out = 10)))

axis(4, at = seq(0, max(test$var.b.prop), length.out = 10), labels = round(seq(0, max(test$var.b), length.out = 10), 2), col = 'red')

mtext("Correct (%)", side=4, line=-1.2, col = 'red')
mtext("Response Time (ms)", side=2, line=-1.2)
darken <- function(color, factor=1.4){
    col <- col2rgb(color)
    col <- col/factor
    col <- rgb(t(col), maxColorValue=255)
    col
}


lighten <- function(color, factor=1.4){
    col <- col2rgb(color)
    col <- col*factor
    col <- rgb(t(col), maxColorValue=255)
    col
}
makeFootnote <- function(footnoteText = format(Sys.time(), "%d %b %Y"), size = 3, color = grey(.5)) {
  require(grid)
  pushViewport(viewport())
  grid.text(label = footnoteText ,
            x = unit(1,"npc") - unit(2, "mm"),
            y = unit(2, "mm"),
            just = c("right", "bottom"),
            gp = gpar(cex = size, col = color))
  popViewport()
}

以上是关于r R绘制#R #plots的主要内容,如果未能解决你的问题,请参考以下文章

R语言使用plotly绘制3D散点图实战

R语言绘制核密度图实战(Kernel Density Plot)

R语言gap.plot函数绘制坐标轴有隔断的可视化图形实战

R语言笔记 plot 画图

R语言plot函数中绘制多条曲线

R语言入门——如何用R绘制尺子