I have a shiny app with server.R
and ui.R
.
This is the code in server.R
:
library(shiny)
library(ggplot2)
library(plotly)
server <- shinyServer(function(input, output, session) {
dat=data.frame(mycolA=c(1,2,3,4), mycolB=c(12,13,16,10), mycolC=c(330,510,290,530))
p=ggplot(dat,aes(x=mycolB, y=mycolC)) +
geom_path(aes(colour=mycolA)) # <----------------------------------
#geom_path()
output$myggplotwithplotly=renderPlotly({
p
})
output$myggplotonly=renderPlot({
p
})
})
This is the code in ui.R
:
library(shiny)
library(ggplot2)
library(plotly)
ui <- shinyUI(fillPage(
fillRow(
plotlyOutput("myggplotwithplotly", height="100%"), plotOutput("myggplotonly", height="100%")
)
))
It returns:
As you see, there is no line in the plotly-diagram on the left.
If I use geom_path()
instead of geom_path(aes(colour=mycolA))
in server.R
then I get:
My Question: Why is the coloured line not displayed in plotly and how do I need to change the code to display it?