Below represents something I am working on. The bottom and right line plots represent projections of the main plot along their respective axis. Contour
When I zoom in on the main plot, I want the projections to zoom according to the xmin, xmax, ymin and ymax and further project only what the main plot is showing, rather than always projecting the main plot entirely.
Is this possible? I tried using event_data("plot_hover") and event_data("plot_selected"), but neither seemed to work. They both came up with null.
There is a lot of documentation for the simpler graphs, but not as much for contours, so I thought I would ask about this one.
Here is a simplified version of my code (Honestly, very crude):
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)
}
})