下面是我正在做的事情。底线图和右线图表示主图沿各自轴的投影。Contour
当我放大主图时,我希望投影根据xmin、xmax、ymin和ymax进行缩放,并进一步投影仅显示主图的内容,而不是始终完全投影主图。
这个是可能的吗?我尝试使用event_data("plot_hover")和event_data("plot_selected"),但似乎都不起作用。他们都想出了null。
有很多关于简单图形的文档,但没有那么多关于等高线的文档,所以我想我应该问一下这个。
以下是我的代码的简化版本(老实说,非常粗糙):
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)
}
})发布于 2017-07-19 06:48:56
已解决:
p <-
plot_ly(x = df[,2], y = df[,4]) %>%
add_contour(x = dat@wavelength, y = dat@data$x, z = dat@data$spc, visible = TRUE) %>%
add_markers(x = df[,2], y = df[,4], opacity = 0.01, hoverinfo="x+y") %>%
layout(dragmode = "select")https://stackoverflow.com/questions/45154340
复制相似问题