条形图中闪亮应用程序中的图例名称未显示

时间:2018-09-24 12:38:04

标签: r shiny

我无法找出条形图未显示图例名称的原因。

图例名称应显示为行名称。但是它以数字显示。

library(shiny)
library(shinydashboard)
library(ggplot2)
bld <- read.csv("C:/Users/velumani_d/Documents/My Dashboard/BLD.csv")
bldr <- rownames(bld)
bldn <- nrow(bld)

ui<- shinyUI(dashboardPage(dashboardBody(fluidPage(
  titlePanel("Block Level"),
  sidebarLayout(
    sidebarPanel(
      selectInput("Visitors", "Select column name:", choices = 
colnames(bld)), hr(), helpText("Data from DESH")),
    mainPanel(plotOutput("Bar_chart"))
  )
))))

server <- shinyServer(function(input,output){
output$Bar_chart <-  renderPlot({
        barplot(bld[,input$Visitors], main = input$Suspected, ylab="No of 
visitors", xlab = "Blocks", legend = bldr, beside = FALSE, col = 1:bldn)
})
    })

shinyApp(ui, server)

数据集:

Block      Visitors Suspected
Amingaon    75      40
Azara       68      23
Chaygaon    80      30
Hajo        728     200
Kamalpur    1814    500
N.Guwahati  529     250
Rangia      49      24
Sualkuchi   1534    400

bar chart

0 个答案:

没有答案