我有一个
image
图形
闪亮的
具有相对大量网格单元格的应用程序。但是,平滑的颜色过渡在浏览器中会出现扭曲。我怀疑这是一个抗锯齿工件,并想知道如何防止它,无论是在R中还是使用css选项。
这里是一个普通R中的最小示例,它看起来像预期的那样平滑:
library(RColorBrewer)
mycol <- colorRampPalette(brewer.pal(11, 'Spectral'))
png("image.png", width=600, height=600)
x <- seq(-0.5, 0.5, length.out = 200)
r <- sqrt(outer(x^2, x^2, `+`))
image(z = cos(r^2) * exp(-r/6), col = mycol(100))
dev.off()
以及相应的
闪亮的
演示,其中生成的图像显示了一个令人讨厌的网格伪影:
library(shiny)
library(RColorBrewer)
mycol <- colorRampPalette(brewer.pal(11, 'Spectral'))
ui <- fluidPage(
plotOutput("imagePlot")
)
server <- function(input, output) {
output$imagePlot <- renderPlot({
x <- seq(-0.5, 0.5, length.out = 200)
r <- sqrt(outer(x^2, x^2, `+`))
image(z = cos(r^2) * exp(-r/6), col = mycol(100))
})
}
shinyApp(ui = ui, server = server)