Title: | Color Palettes Based on Fish Species |
---|---|
Description: | Implementation of color palettes based on fish species. |
Authors: | Nina M. D. Schiettekatte [cre, aut], Simon J. Brandl [aut], Jordan M. Casey [aut] |
Maintainer: | Nina M. D. Schiettekatte <[email protected]> |
License: | GPL-2 |
Version: | 0.2.3 |
Built: | 2025-03-30 05:12:38 UTC |
Source: | https://github.com/nschiett/fishualize |
Adds a fish silhouette to your plot
add_fishape( family = "Pomacanthidae", option = "Centropyge_loricula", xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, scaled = FALSE, xlim = NULL, ylim = NULL, fill = "#000000", alpha = 1 )
add_fishape( family = "Pomacanthidae", option = "Centropyge_loricula", xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, scaled = FALSE, xlim = NULL, ylim = NULL, fill = "#000000", alpha = 1 )
family |
character string indicating the fish family. |
option |
character string indicating the fish species. If NA, the first available option within a family will be selected |
xmin |
x location giving minimum horizontal location of silhouette |
xmax |
x location giving maximum horizontal location of silhouette |
ymin |
y location giving minimum vertical location of silhouette |
ymax |
y location giving maximum vertical location of silhouette |
scaled |
logical parameter. If TRUE, location parameters (xmin, xmax, ymin, ymax) should range between 0 and 1. If FALSE, location parameters should be provided according to the values on the plot axes. |
xlim , ylim
|
vectors of length = 2, contains the data limits and must be provided if scaled is TRUE. |
fill |
color of fish shape |
alpha |
transparency of fish shape (value between 0 and 1) |
Adds a fish silhouette grob to a ggplot object.
## Not run: library(ggplot2) ggplot() + add_fishape(fill = fish(n = 5)[4]) ggplot(diamonds)+ geom_bar(aes(cut, fill = cut)) + scale_fill_fish_d(option = "Naso_lituratus") + add_fishape(family = "Acanthuridae", option = "Naso_unicornis", xmin = 1, xmax = 3, ymin = 15000, ymax = 20000, fill = fish(option = "Naso_lituratus", n = 5)[3], alpha = 0.8) + theme_bw() ## example with relative coordinates ggplot(diamonds)+ geom_bar(aes(cut, fill = cut)) + scale_fill_fish_d(option = "Naso_lituratus") + add_fishape(family = "Acanthuridae", option = "Naso_unicornis", xmin = 0, xmax = 0.3, ymin = 0.8, ymax = 1, scaled = TRUE, xlim = c(0.5, 5.5), ylim = c(0, 21000) , fill = fish(option = "Naso_lituratus", n = 5)[3], alpha = 1) + theme_bw() ## End(Not run)
## Not run: library(ggplot2) ggplot() + add_fishape(fill = fish(n = 5)[4]) ggplot(diamonds)+ geom_bar(aes(cut, fill = cut)) + scale_fill_fish_d(option = "Naso_lituratus") + add_fishape(family = "Acanthuridae", option = "Naso_unicornis", xmin = 1, xmax = 3, ymin = 15000, ymax = 20000, fill = fish(option = "Naso_lituratus", n = 5)[3], alpha = 0.8) + theme_bw() ## example with relative coordinates ggplot(diamonds)+ geom_bar(aes(cut, fill = cut)) + scale_fill_fish_d(option = "Naso_lituratus") + add_fishape(family = "Acanthuridae", option = "Naso_unicornis", xmin = 0, xmax = 0.3, ymin = 0.8, ymax = 1, scaled = TRUE, xlim = c(0.5, 5.5), ylim = c(0, 21000) , fill = fish(option = "Naso_lituratus", n = 5)[3], alpha = 1) + theme_bw() ## End(Not run)
This function creates a vector of n
equally spaced colors along the
'fish colour map' of your selection
fish( n, alpha = 1, begin = 0, end = 1, direction = 1, option = "Centropyge_loricula" ) fish_pal( alpha = 1, begin = 0, end = 1, direction = 1, option = "Centropyge_loricula" )
fish( n, alpha = 1, begin = 0, end = 1, direction = 1, option = "Centropyge_loricula" ) fish_pal( alpha = 1, begin = 0, end = 1, direction = 1, option = "Centropyge_loricula" )
n |
The number of colors ( |
alpha |
The alpha transparency, a number in [0,1], see argument alpha in
|
begin |
The (corrected) hue in [0,1] at which the fish colormap begins. |
end |
The (corrected) hue in [0,1] at which the fish colormap ends. |
direction |
Sets the order of colors in the scale. If 1, the default, colors are ordered from darkest to lightest. If -1, the order of colors is reversed. |
option |
A character string indicating the fish species to use. |
fish
returns a character vector, cv
, of color hex
codes. This can be used either to create a user-defined color palette for
subsequent graphics by palette(cv)
, a col =
specification in
graphics functions or in par
.
Semi-transparent colors () are supported only on some
devices: see
rgb
.
library(ggplot2) library(fishualize) dat <- data.frame(x = rnorm(1e4), y = rnorm(1e4)) ggplot(dat, aes(x = x, y = y)) + stat_density_2d(geom = "raster", aes(fill = after_stat(density)), contour = FALSE) + scale_fill_gradientn(colors = fish(128, option = 'Ostracion_cubicus')) pal <- fish(256, option = "Thalassoma_hardwicke", direction = -1) image(volcano, col = pal)
library(ggplot2) library(fishualize) dat <- data.frame(x = rnorm(1e4), y = rnorm(1e4)) ggplot(dat, aes(x = x, y = y)) + stat_density_2d(geom = "raster", aes(fill = after_stat(density)), contour = FALSE) + scale_fill_gradientn(colors = fish(128, option = 'Ostracion_cubicus')) pal <- fish(256, option = "Thalassoma_hardwicke", direction = -1) image(volcano, col = pal)
This function returns a vector containing the names of all the available palettes in the 'fishualize' package.
fish_palettes()
fish_palettes()
fish_palettes
returns a character vector with the names of the fish palettes available to use.
fish_palettes()
fish_palettes()
This function returns a dataframe containing the all the available fish silhouettes accessible through the 'fishualize' package.
fishapes()
fishapes()
fishapes
returns a dataframe containing the all the available fish
silhouettes available to use.
fishapes()
fishapes()
A dataset containing some colour palettes inspired by fish species
fishcolors
fishcolors
A data frame containing all the colours used in the palette:
option: It is intended to be a general option for choosing the specific colour palette.
hex: hex color code
This function creates an image of the specified fish color palette.
fishualize(option = "Centropyge_loricula", n = 5, ...)
fishualize(option = "Centropyge_loricula", n = 5, ...)
option |
A character string indicating the fish species to use. |
n |
The number of colors ( |
... |
Other arguments as can be specified in the function |
fishualize
returns a visualisation of the specified color palette.
fishualize::fishualize() fishualize::fishualize(option = "Zanclus_cornutus", n = 8)
fishualize::fishualize() fishualize::fishualize(option = "Zanclus_cornutus", n = 8)
Uses the fish color scale.
scale_color_fish( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1, discrete = FALSE ) scale_colour_fish( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1, discrete = FALSE ) scale_colour_fish_d( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1 ) scale_color_fish_d( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1 ) scale_fill_fish_d( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1 ) scale_fill_fish( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1, discrete = FALSE )
scale_color_fish( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1, discrete = FALSE ) scale_colour_fish( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1, discrete = FALSE ) scale_colour_fish_d( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1 ) scale_color_fish_d( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1 ) scale_fill_fish_d( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1 ) scale_fill_fish( option = "Centropyge_loricula", ..., alpha = 1, begin = 0, end = 1, direction = 1, discrete = FALSE )
option |
A character string indicating the fish species to use. |
... |
parameters to |
alpha |
pass through parameter to |
begin |
The (corrected) hue in [0,1] at which the fish colormap begins. |
end |
The (corrected) hue in [0,1] at which the fish colormap ends. |
direction |
Sets the order of colors in the scale. If 1, the default, colors
are as output by |
discrete |
generate a discrete palette? (default: |
For discrete == FALSE
(the default) all other arguments are as to
scale_fill_gradientn or scale_color_gradientn.
Otherwise the function will return a discrete_scale
with the plot-computed
number of colors.
Alias of scale_color_fish or scale_fill_fish
Alias of scale_color_fish or scale_fill_fish
Alias of scale_color_fish or scale_fill_fish
Alias of scale_color_fish or scale_fill_fish
Alias of scale_color_fish or scale_fill_fish
library(ggplot2) library(fishualize) ggplot(diamonds, aes(factor(cut), fill=factor(cut))) + geom_bar() + scale_fill_fish(discrete = TRUE, option = "Centropyge_loricula") ggplot(mtcars, aes(factor(gear), fill=factor(carb))) + geom_bar() + scale_fill_fish(discrete = TRUE, option = "Trimma_lantana") ggplot(mtcars, aes(x = mpg, y = disp, colour = drat)) + geom_point(size = 4) + scale_colour_fish(option = "Ostracion_cubicus", direction = -1)
library(ggplot2) library(fishualize) ggplot(diamonds, aes(factor(cut), fill=factor(cut))) + geom_bar() + scale_fill_fish(discrete = TRUE, option = "Centropyge_loricula") ggplot(mtcars, aes(factor(gear), fill=factor(carb))) + geom_bar() + scale_fill_fish(discrete = TRUE, option = "Trimma_lantana") ggplot(mtcars, aes(x = mpg, y = disp, colour = drat)) + geom_point(size = 4) + scale_colour_fish(option = "Ostracion_cubicus", direction = -1)