View source: R/optimize_palette.R
optimize_palette | R Documentation |
taken a raw palette created from a jpeg image, optimizes it given the type of variable to be plotted
optimize_palette( rgb_raw_palette = NA, number_of_colors = NA, type_of_variable = "categorical", effective_n_of_color = NA, filter_on_low_brightness = NA, filter_on_high_brightness = NA, filter_on_saturation = NA )
rgb_raw_palette |
numeric matrix of RGB from a call to rgb on hex codes |
type_of_variable |
string, default to 'categorical'. type of variable to be plotted with the building palette |
effective_n_of_color |
integere, the actual number of colors obtained from the application of kmeans on the image. equal to number_of_colours *100 |
filter_on_low_brightness |
boolean, default to true. specifies if a filter on colours with low brigthness should be applied to enhance the palette |
filter_on_high_brightness |
boolean, default to true. specifies if a filter on colours with high brigthness should be applied to enhance the palette |
filter_on_saturation |
boolean, default to ture. specifies if a filter on low saturation should be applied. |
number_of_colours |
integer, number of desired colours in the final palette, as specified by the user when calling create_palette |
palette optimization consists into four different steps: - conversion to hsv scale in order to easily elavorate on colour order and properties. - filter on colours with a brightness lower than the first quartile of v distribution - filter on colours with a brightness higher or equal to the Tukey's outlier threshold computed on the overall v distribution - subset of the palette according to the type of variable to be plotted: a spaced sample in case of categorical variables, an interpolation between two colours close to the mode of h for continuous variables
Andrea Cirillo
create_palette("data/nascita_venere.jpg",number_of_colors = 20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.