首页 > 解决方案 > 闪亮应用程序条形图中的图例名称未显示

问题描述

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

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

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

条形图

标签: rshiny

解决方案


推荐阅读