从rChart中删除图例

时间:2017-12-17 14:56:55

标签: r rcharts

我在Shiny应用程序中使用rCharts库,并希望删除右侧图例。

我发现的提示在这种情况下不起作用...... 例如:p1$chart(showLegend = FALSE)

我的代码与此类似:

library(rCharts)

mydata<-data.frame(weekday=c("friday","monday","thursday","tuesday","saturday","sunday","wednesday"),value=rnorm(7,10,2))


p1<-rPlot(value ~ weekday, color = 'weekday', data = mydata, type = 'bar')

  p1$guides(
    color = list(
      numticks = length(unique(mydata$weekday))
    ),
    x = list(title="",
             ticks = c('sunday', 'monday', 'tuesday','wednesday','thursday','friday','saturday'),
             labels ="",
             levels = c('sunday', 'monday', 'tuesday','wednesday','thursday','friday','saturday')
    ),
    y = list(title=""
    )
  )


  p1$chart(showLegend = FALSE)

p1

1 个答案:

答案 0 :(得分:1)

我使用以下代码行解决了问题:

  p1$set(legendPosition = "none")