1
請看下面的非常簡單的例子:plotlyOutput與geom_bar沒有顯示負值
library(shiny)
library(plotly)
ui <- basicPage(
plotlyOutput("plot")
)
server <- function(input, output) {
df <- data.frame(SomeX = c("Cat1", "Cat2", "Cat3", "Cat1", "Cat2", "Cat3"),
SomeFill = c("a", "a", "a", "b", "b", "b"),
SomeY = c(2, 3, 4, -4, 7, 3))
output$plot <- renderPlotly({
ggplot(df, aes(x = SomeX, y = SomeY, fill=SomeFill)) +
geom_bar(stat = "identity")
})
}
shinyApp(ui, server)
出於某種原因,它並不顯示值-4正常輸出。它顯示的值就好像是+4。這是從代碼的結果不同(使用情節而不是plotly):
library(shiny)
library(plotly)
ui <- basicPage(
plotOutput("plot")
)
server <- function(input, output) {
df <- data.frame(SomeX = c("Cat1", "Cat2", "Cat3", "Cat1", "Cat2", "Cat3"),
SomeFill = c("a", "a", "a", "b", "b", "b"),
SomeY = c(2, 3, 4, -4, 7, 3))
output$plot <- renderPlot({
ggplot(df, aes(x = SomeX, y = SomeY, fill=SomeFill)) +
geom_bar(stat = "identity")
})
}
shinyApp(ui, server)
這是一個錯誤還是我做錯了什麼?
這是一個錯誤,請參閱https://github.com/ropensci/plotly/issues/560 –