【问题标题】:rCharts - not show x axis elementsrCharts - 不显示 x 轴元素
【发布时间】:2014-09-21 04:42:47
【问题描述】:

我有一个 rPlot,我不希望它显示 x 轴下方元素的名称。我已经使用以下代码完成了此操作,但在绘图上方出现错误。这个词是隐藏的,但如果我双击、复制和粘贴,我会看到这个词是“未定义的”。如果我下线:

,numticks = 'none'

错误没有出现。

我需要其他解决方案来隐藏名称或修复这个。

提前致谢!

路易斯

ui.R

shinyUI(pageWithSidebar(

  headerPanel("New Application"),

  sidebarPanel(

           selectInput('feature', 'Choose a variable:', colnames(mtcars))


  ),

  mainPanel(
    showOutput('plot32', 'polycharts')
  )
))

服务器.R

shinyServer(function(input, output) {

  mydata<- reactive({
    Feature<-input$feature
    mtcars2<-cbind(rownames(mtcars),mtcars)
    colnames(mtcars2)<-c("Cars",colnames(mtcars))

    a<-mtcars2[,c("Cars",Feature)]
    colnames(a)<-c("Cars","Feature")
    a
  })


  output$plot32<- renderChart2({
    data2<-mydata()
    Feature<-input$feature
    p1<-rPlot(Feature ~ Cars, color = 'Cars', data = data2, type = 'bar')
    p1$guides(
      color = list(
        numticks = length((data2[,1]))
      ),
      x = list(title="Cars",
               numticks = 'none'
      ),
      y = list(title=input$feature
      )
    )
    p1$addParams(width = 800, height = 400, 
                 title = "Title")
    p1
  })

})

【问题讨论】:

    标签: r shiny rcharts


    【解决方案1】:

    终于找到了解决办法:

    shinyServer(function(input, output) {
    
      mydata<- reactive({
        Feature<-input$feature
        mtcars2<-cbind(rownames(mtcars),mtcars)
        colnames(mtcars2)<-c("Cars",colnames(mtcars))
    
        a<-mtcars2[,c("Cars",Feature)]
        colnames(a)<-c("Cars","Feature")
        a
      })
    
    
      output$plot32<- renderChart2({
        data2<-mydata()
        Feature<-input$feature
        p1<-rPlot(Feature ~ Cars, color = 'Cars', data = data2, type = 'bar')
        p1$guides(
          color = list(
            numticks = length((data2[,1]))
          ),
    

    x = list(title="汽车", ticks='' ),

    y = list(title=input$feature
          )
        )
        p1$addParams(width = 800, height = 400, 
                     title = "Title")
        p1
      })
    
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 2012-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多