该shinysky软件包有一个颜色选择器,您可以使用shiny:
require(shinysky)
require(shiny)
runApp(list(
ui = bootstrapPage(
jscolorInput("colorid"),
uiOutput('myPanel'),
plotOutput('plot')
),
server = function(input, output) {
output$myPanel <- renderUI({
mystyle <- ifelse(is.null(input$colorid), "ffffff", input$colorid)
inputPanel(
numericInput('n', 'Number of obs', 100)
, style = paste0("background-color:#", mystyle, ";")
)
})
output$plot <- renderPlot({ hist(runif(input$n)) })
}
))
Run Code Online (Sandbox Code Playgroud)

它目前不在CRAN上,因此您需要通过devtools详细信息安装它,请访问https://github.com/AnalytixWare/ShinySky
对于来这里寻找颜色选择器的人来说,之前使用的答案shinysky已经过时了(那里的颜色选择器已移至不在维护状态的包中)
在shinyjs包中还有另一个可用于shiny 的颜色选择器。
library(ggplot2)
library(shiny)
library(shinyjs)
runApp(shinyApp(
ui = fluidPage(
colourInput("col", "Select colour", "grey"),
plotOutput("plot")
),
server = function(input, output, session) {
output$plot <- renderPlot({
ggplot(cars, aes(speed, dist)) +
geom_point() +
theme(panel.background = element_rect(fill = input$col))
})
}
))
Run Code Online (Sandbox Code Playgroud)

免责声明:我是这个包的作者。
| 归档时间: |
|
| 查看次数: |
827 次 |
| 最近记录: |