0
下面是我正在处理的内容。底部和右边的线条图代表主要地块沿各自轴线的投影。 ContourShiny - > Plotly-> Contour - > event_data()
当我放大的主要情节,我想预测,以根据XMIN,XMAX,y最小和y,并进一步项目仅缩放什么的主要情节是展示,而不是总是完全突出的主要情节。
这可能吗?我尝试使用event_data(“plot_hover”)和event_data(“plot_selected”),但都没有效果。他们都提出了空。
对于更简单的图表有很多文档,但对轮廓没有太多,所以我想我会问这个。
这里是我的代码(老实说,很简陋)的简化版本:
ui.R
shinyUI(dashboardPage(
dashboardHeader(title = "Oscillations in Spectroscopy"),
dashboardSidebar(sidebarMenu(
id = "mytabs",
menuItem(
"Data Input",
tabName = "input",
icon = icon("dashboard")
)
)),
dashboardBody(tabItems(tabItem(
"input",
box(
title = "Data Input",
status = "warning",
solidHeader = TRUE,
width = "100%",
height = "100%",
fluidPage(fluidRow(
column(7,
plotlyOutput("raw"),
plotlyOutput("raw.x")),
column(2, width = 5,
plotlyOutput("raw.y"))
))
)
)))
))
Server.r
shinyServer(function(input, output, session) {
process.data <- reactive({
#Do some back - end stuff
return(df)
})
output$raw <- renderPlotly({
print(.mainplot())
})
output$raw.x <- renderPlotly({
.xplot()
})
output$raw.y <- renderPlotly({
.yplot()
})
.mainplot <- function() {
df <- data.frame(process.data())
p <-
plot_ly(
df,
x = ~ series,
y = ~ time,
z = ~ value,
type = "contour",
source = "A"
) %>% hide_colorbar()
return (p)
}
.xplot <- function() {
df <- data.frame(process.data())
p <-
plot_ly(
df,
x = ~ series,
y = ~ value,
type = 'scatter',
mode = 'lines'
) %>%
layout(xaxis = list(title = ""),
yaxis = list(title = "", showticklabels = F))
return(p)
}
.yplot <- function() {
df <- data.frame(process.data())
p <-
plot_ly(
df,
x = ~ x,
y = ~ y,
type = 'scatter',
mode = 'lines'
) %>%
layout(xaxis = list(title = ""),
yaxis = list(title = "", showticklabels = F))
return (p)
}
})