r - 为什么我的第二个 ggplot 没有出现在我闪亮的应用程序中?
问题描述
使用棒球数据创建闪亮的应用程序。当我运行以下命令时,除了第二个图(折线图)外,一切看起来都很好。我确定我错过了一些小东西,但我无法解决它。
ui <- fluidPage(
selectInput(inputId = "num1",
label = "Select Pitcher",
choices = levels(PitcherName),
selected = NULL
),
fluidRow(plotOutput("PitchLoc"), width = 5,
plotOutput("PitchVol"), width = 5)
)
server <- function(input, output) {
output$PitchLoc <-renderPlot({
bp <- GameData %>% filter(PitcherName == input$num1,
)
ggplot(bp, aes(x=PlateLocSide, y=PlateLocHeight)) +
geom_point(aes(color = TaggedPitchType)) +
scale_color_manual(values = c('black','blue','red','purple','yellow')) +
geom_path(data = sz, aes(x=x, y=z)) +
xlim(-3,3) +
ylim(0,6) +
ggtitle("Pitch Location by Pitch Type")
})
output$PitchVol <-renderPlot({
vol <- GameData %>% filter(PitchSelect %in% c("Fastball", "Curveball", "Slider", "ChangeUp"),
Pitcher == input$num1
) %>%
ggplot(aes(x=PitchNo, y=RelSpeed,)) +
geom_line(aes(group=TaggedPitchType, color=TaggedPitchType)) +
ggtitle("Pitch Velocity")
})
}
shinyApp(ui = ui, server = server)
解决方案
您的 plotOutput 宽度在括号之外,即
fluidRow(plotOutput("PitchLoc", width = 5),
plotOutput("PitchVol", width = 5))
推荐阅读
- flutter - Flutter Riverpod - 提供来自异步调用的对象的初始化/覆盖提供程序
- python - 在 Python 中从字符串中删除子字符串
- mysql - MariaDB REGEXP_REPLACE 在替换字符串中带有分号会引发错误
- powershell - powershell 字符串替换内联或新循环
- c - 如何OpenMP并行嵌套for循环不能折叠
- swift - 无法显示来自 Firestore 的数据,但添加工作正常
- python - 如何以原生 Pytorch 格式定义模型并导入 LightningModule,无需复制和粘贴?
- python - Pandas - 以特定子字符串结尾的字符串向下传播,直到列出新的字符串
- php - 为什么我在渲染新页面时无法访问 php 变量
- javascript - Three.js 对象无法呈现 - 无法在“WebGL2RenderingContext”上执行“uniform3fv”:重载解析失败