File:Rainbow default.png

From 太極
Jump to navigation Jump to search

Original file(2,044 × 1,182 pixels, file size: 426 KB, MIME type: image/png)

Summary

library(shiny)

# Define the UI
ui <- fluidPage(
  titlePanel("Rainbow Color Palette"),
  sidebarLayout(
    sidebarPanel(
      sliderInput("s_value", "Saturation (s):", min = 0, max = 1, value = 1, step = 0.01),
      sliderInput("v_value", "Value (v):", min = 0, max = 1, value = 1, step = 0.01)
    ),
    mainPanel(
      plotOutput("rainbow_plot")
    )
  )
)

# Define the server
server <- function(input, output) {
  output$rainbow_plot <- renderPlot({
    s <- input$s_value
    v <- input$v_value
    rainbow_colors <- rainbow(12, s = s, v = v)
    
    # Plot the colors
    barplot(rep(1, 12), col = rainbow_colors, border = NA, space = 0)
  })
}

# Run the Shiny app
shinyApp(ui = ui, server = server)

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current08:52, 12 March 2024Thumbnail for version as of 08:52, 12 March 20242,044 × 1,182 (426 KB)Brb (talk | contribs)<syntaxhighlight lang='r'> library(shiny) # Define the UI ui <- fluidPage( titlePanel("Rainbow Color Palette"), sidebarLayout( sidebarPanel( sliderInput("s_value", "Saturation (s):", min = 0, max = 1, value = 1, step = 0.01), sliderInput("v_value", "Value (v):", min = 0, max = 1, value = 1, step = 0.01) ), mainPanel( plotOutput("rainbow_plot") ) ) ) # Define the server server <- function(input, output) { output$rainbow_plot <- renderPlot({ s <-...

The following page uses this file:

Metadata