大家好,
我使用rgl和shinyrgl在我的Shiny应用程序中生成3D PCA图。然后,我使用legend3d
函数创建图例。从上图中可以看出,图例的分辨率明显低于图表。还有其他人遇到过这个问题吗?
我已经包含了用于绘制此内容的代码。由于它的闪亮,制作一个完整的工作示例有点困难。我还想看看是否还有其他人解决了这个问题。
马特
tabItem(tabName = "3DTab",
fluidRow(
column(6,
rglwidgetOutput(outputId = "TDPCA")),
column(6,
box(title = "Customisation",
width = NULL,
collapsible = TRUE,
selectizeInput(inputId = "TDPCAClass",
label = "Class",
choices = c("Day"))))
output$TDPCA <- renderRglwidget({
plot3d(x = TDPCA()$PC1, y = TDPCA()$PC2, z = TDPCA()$PC3, col = TDPCA()[[input$TDPCAClass]],
xlab = paste("PC1", "-", TDPCA.var()["PC1"], "%"), ylab = paste("PC2", "-", TDPCA.var()["PC2"], "%"), zlab = paste("PC3", "-", TDPCA.var()["PC3"], "%"), type = "p")
legend3d("topright",
legend = c("Monday", "Tuesday", "Wednesday", "Thursday", "Saturday"),
pch = 16,
col = palette("default"),
cex=0.65, inset=c(0))
rglwidget()
})
答案 0 :(得分:2)
是的,legend3d
的帮助页面中提到了该问题。问题是为当前的rgl窗口大小生成了图例,可以在以后调整大小。你想在调整大小后生成它。
我不太确定你是否可以查询Shiny有关渲染rgl窗口的大小,但有一种可能性只是猜测,例如。
output$TDPCA <- renderRglwidget({
plot3d(x = TDPCA()$PC1, y = TDPCA()$PC2, z = TDPCA()$PC3, col = TDPCA()[[input$TDPCAClass]],
xlab = paste("PC1", "-", TDPCA.var()["PC1"], "%"), ylab = paste("PC2", "-", TDPCA.var()["PC2"], "%"), zlab = paste("PC3", "-", TDPCA.var()["PC3"], "%"), type = "p")
par3d(windowRect = c(0, 0, 512, 512))
legend3d("topright",
legend = c("Monday", "Tuesday", "Wednesday", "Thursday", "Saturday"),
pch = 16,
col = palette("default"),
cex=0.65, inset=c(0))
rglwidget()
})
编辑添加:此页面Spring MVC's documentation讨论动态设置大小。