emilioxavier / theHUB

https://theHopefulBox.com/
Other
2 stars 0 forks source link

Create a function for creating colour ramps with bins for ranges of values #36

Open emilioxavier opened 11 months ago

emilioxavier commented 11 months ago

Hi Please create a function for creating colour ramps with bins for ranges of values based on the code below. Initially, the parameters will be the "low colour", the "high colour", and the type name. The manual page should indicate that the resulting colour ramp only works for values between 0 and 1; thus, the values of interest need to be scaled from 0 to 1.

purple.heatmap <- colorRampPalette(colors=c("#6a51a3", "#dadaeb"), bias=1,
                                   space="rgb", interpolate="linear", alpha=FALSE)

purple.ramp <- tibble::tibble(hex=purple.heatmap(102),
                                     start=c(0, seq(from=0.00, to=0.99, by=0.01), 1),
                                     stop=c(0, seq(from=0.01, to=1, by=0.01), 1)) |>
  add_column(type="blah")

I fully understand that this is a short collection of code to create a colour ramp, but having a single function will reduce repeating this code for the various colour ramps created.

Thank you! Emilio