bluemira.display.palettes ========================= .. py:module:: bluemira.display.palettes .. autoapi-nested-parse:: Colour palettes Attributes ---------- .. autoapisummary:: bluemira.display.palettes.BLUEMIRA_PALETTE bluemira.display.palettes.LONDON_PALETTE bluemira.display.palettes.BLUE_PALETTE Classes ------- .. autoapisummary:: bluemira.display.palettes.ColorPalette Functions --------- .. autoapisummary:: bluemira.display.palettes.background_colour_string bluemira.display.palettes.make_rgb_alpha bluemira.display.palettes.make_alpha_palette bluemira.display.palettes.colour_string Module Contents --------------- .. py:class:: ColorPalette(palette_map: dict[str, matplotlib.typing.ColorType]) Color palette object, wrapping some seaborn functionality. :param palette_map: Dictionary of color names to any object matplotlib will recognise as a color .. py:attribute:: _dict .. py:attribute:: _palette :value: [] .. py:attribute:: _cycle .. py:method:: keys() :returns: Keys of ColorPalette .. py:method:: __next__() :returns: the next color in the ColorPalette .. py:method:: __setitem__(idx_or_key: int | str, value: matplotlib.typing.ColorType | ColorPalette) Set an item in the ColorPalette by index or key :param idx_or_key: Index or key of the ColorPalette :param value: The value to set. Note that this can be another ColorPalette .. py:method:: __getitem__(idx_or_key: int | str) -> matplotlib.typing.ColorType | ColorPalette | None Get an item in the ColorPalette by index or key :param idx_or_key: Index or key of the ColorPalette :returns: The value. Note that this can be another ColorPalette :rtype: value .. py:method:: _hex_horizontal() -> list[str] | list[list[str]] :returns: A list of strings representing a horizontal row of hex colors, or a list of lists of strings where each inner list represents a row of hex colors. .. py:method:: _repr_html() -> str .. py:method:: _repr_colour_str(_hex: list[str] | list[list[str]]) -> str :returns: colourful representation in terminal .. py:method:: __repr__() -> str :returns: a representation of the ColorPalette .. py:method:: __len__() -> int :returns: the length of the ColorPalette .. py:method:: as_hex() -> list[str] | list[list[str]] | str :returns: the hex representation of the palette .. py:function:: background_colour_string(hexstring: str, sqlen=2) -> str :returns: ANSI background colour string for hex colour .. py:function:: make_rgb_alpha(rgb: tuple[float, Ellipsis], alpha: float, background_rgb: tuple[float, Ellipsis] = (1.0, 1.0, 1.0)) -> tuple[float, Ellipsis] Adds a transparency to a RGB color tuple :param rgb: Tuple of 3 RGB floats (0<=float<=1) :param alpha: Transparency as a fraction (0<=float<=1) :param background_rgb: 3 RGB floats (0<=float<=1), background colour (default = white) :rtype: The RGB tuple accounting for transparency .. py:function:: make_alpha_palette(color, n_colors: int, background_rgb: matplotlib.typing.ColorType = 'white') -> ColorPalette Make a palette from a color by varying alpha. :param color: Palette base color. Anything matplotlib will recognise as a color :type color: Any :param n_colors: Numer of colors to make in the palette :param background_rgb: Background color. Anything matplotlib will recognise as a color :returns: Colour palette from the base color. The first color is the base color .. py:function:: colour_string(string: str, colour: str) -> str Colour a string with ANSI codes :param string: The text to colour :param colour: The colour to make the colour-string for :returns: The string with ANSI colour decoration .. py:data:: BLUEMIRA_PALETTE .. py:data:: LONDON_PALETTE .. py:data:: BLUE_PALETTE