### Install distinctipy for development Source: https://github.com/alan-turing-institute/distinctipy/blob/main/README.md Install distinctipy along with dependencies needed for testing, documentation generation, and other development tasks. ```bash python -m pip install distinctipy[extras,tests,docs] ``` -------------------------------- ### Install distinctipy with extras Source: https://github.com/alan-turing-institute/distinctipy/blob/main/README.md Install distinctipy with optional dependencies like matplotlib and pandas, which are required for features like color swatches and examples. ```bash python -m pip install distinctipy[extras] ``` -------------------------------- ### Install distinctipy Source: https://github.com/alan-turing-institute/distinctipy/blob/main/README.md Install the distinctipy package using pip. This command installs the core package. ```shell python -m pip install distinctipy ``` -------------------------------- ### Install Optional Dependencies Separately Source: https://github.com/alan-turing-institute/distinctipy/blob/main/docs/install.md Install matplotlib and pandas separately if you need them for distinctipy's visualization features but do not want to use the '[extras]' flag during initial installation. ```bash pip install matplotlib pandas ``` -------------------------------- ### Install distinctipy from source Source: https://github.com/alan-turing-institute/distinctipy/blob/main/README.md Clone the repository and install distinctipy locally using pip. This is useful for development or when you need the latest changes. ```shell git clone https://github.com/alan-turing-institute/distinctipy.git cd distinctipy python -m pip install . ``` -------------------------------- ### Install matplotlib and pandas separately Source: https://github.com/alan-turing-institute/distinctipy/blob/main/README.md Install matplotlib and pandas as separate packages if you need them for distinctipy features like color swatches. ```bash python -m pip install matplotlib pandas ``` -------------------------------- ### Generate Distinct Colors and Text Colors Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Generates a specified number of distinct colors, inverts them, determines optimal text colors (black or white) for each background, and displays them in a color swatch. Requires distinctipy library. ```python # generate 36 distinct colours colors = distinctipy.get_colors(36) # generate a colour as distinct as possible from each colour in colors inverted = distinctipy.invert_colors(colors) # pick black or white text for each colour text = [distinctipy.get_text_color(color) for color in colors] # display main colours, inverted colours and text distinctipy.color_swatch(colors, edgecolors=inverted, show_text=True) ``` -------------------------------- ### Generate and display distinct colors Source: https://github.com/alan-turing-institute/distinctipy/blob/main/README.md Generate a specified number of visually distinct colors and display them using a color swatch. This is a common use case for the library. ```python import distinctipy # number of colours to generate N = 36 # generate N visually distinct colours colors = distinctipy.get_colors(N) # display the colours distinctipy.color_swatch(colors) ``` -------------------------------- ### Simulate Colorblindness in Images Source: https://github.com/alan-turing-institute/distinctipy/blob/main/docs/usage.ipynb Simulate how an image appears under different types of colorblindness (Protanopia, Deuteranopia, Tritanopia, Achromatopsia, etc.) using `distinctipy.colorblind.simulate_image`. This is useful for accessibility testing and ensuring designs are perceivable by individuals with color vision deficiencies. ```python # path to image (PNG only) img_path = "https://raw.githubusercontent.com/alan-turing-institute/distinctipy/main/distinctipy/datasets/test.png" # type of colourblindness to simulate colorblind_type = "Protanopia" # compare appearance of image with and without colourblindness colorblind.simulate_image(img_path, colorblind_type) ``` -------------------------------- ### Compare Distinctipy with Other Color Maps for Clusters Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Compares distinctipy's color mapping for a cluster dataset (e.g., 'a3') against another specified colormap (e.g., 'nipy_spectral'). Useful for visualizing how distinctipy handles clustered data compared to alternatives. ```python # compare distinctipy and nipy_spectral colourmaps for a 50 cluster dataset examples.compare_clusters("a3", compare_with="nipy_spectral") ``` -------------------------------- ### Compare Clusters with Colorblindness Correction Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Visualizes data clusters, comparing how they appear with standard colors versus colors optimized for Deuteranomaly colorblindness. This helps in assessing the impact of colorblindness correction on data interpretation. ```python colorblind_type = "Deuteranomaly" dataset = "s3" print("Colours distinct for normal vision:") colorblind.simulate_clusters( dataset=dataset, colorblind_type=colorblind_type, colorblind_distinct=False ) print("Colours distinct for " + colorblind_type + " colourblindness:") colorblind.simulate_clusters( dataset=dataset, colorblind_type=colorblind_type, colorblind_distinct=True ) ``` -------------------------------- ### Generate Colors Distinct from Input Colors Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Use this to generate new colors that are as distinct as possible from a predefined list of colors. Useful when you have already used certain colors and need to find new ones that stand out. ```python import distinctipy from distinctipy import colorblind from distinctipy import examples import matplotlib.pyplot as plt # rgb colour values (floats between 0 and 1) RED = (1, 0, 0) GREEN = (0, 1, 0) BLUE = (0, 0, 1) WHITE = (1, 1, 1) BLACK = (0, 0, 0) # generated colours will be as distinct as possible from these colours input_colors = [RED, GREEN, BLUE, WHITE, BLACK] # generate 5 new colours output_colors = distinctipy.get_colors(5, input_colors) # display the colours fig, axes = plt.subplots(2, 1, figsize=(6, 6)) distinctipy.color_swatch(input_colors, ax=axes[0], title="Input Colours") distinctipy.color_swatch(output_colors, ax=axes[1], title="Output Colours") ``` -------------------------------- ### Simulate Colorblindness on an Image Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Simulates the appearance of an image under a specific type of colorblindness (e.g., 'Protanopia'). Requires the image path and the type of colorblindness to simulate. Supports PNG images. ```python # path to image (PNG only) img_path = "https://raw.githubusercontent.com/alan-turing-institute/distinctipy/main/distinctipy/datasets/test.png" # type of colourblindness to simulate colorblind_type = "Protanopia" # compare appearance of image with and without colourblindness colorblind.simulate_image("distinctipy/datasets/test.png", colorblind_type) ``` -------------------------------- ### Compare Distinctipy with Matplotlib Palettes Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Compares colors generated by distinctipy with a specified matplotlib palette (e.g., 'tab20') for a given number of colors. Useful for evaluating distinctipy's performance against standard colormaps. ```python # compare 40 colours generated with the distinctipy and tab20 colour palettes examples.compare_colors(N=40, compare_with="tab20") ``` -------------------------------- ### Generate N Distinct Pastel Colors Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Generate a specified number of visually distinct pastel colors by using the pastel_factor parameter. This is useful for creating softer, lighter color palettes. ```python # generate 36 distinct pastel colours colors = distinctipy.get_colors(36, pastel_factor=0.7) # display the colours distinctipy.color_swatch(colors) ``` -------------------------------- ### Generate Distinct Colors for Colorblindness Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Compares default color palettes with those optimized for a specific colorblindness type (Tritanopia). Use this to see how distinctipy adjusts colors for better visibility. ```python # type of colourblindness to simulate colorblind_type = "Tritanopia" # number of colours to generate N = 4 # how default distinctipy colours look for Tritanopia print("Colours distinct for normal vision:") norm_colors = distinctipy.get_colors(N, colorblind_type=None) colorblind.simulate_colors(norm_colors, colorblind_type=colorblind_type) # how colours optimised for distinction with Tritanopia look print("Colours distinct for " + colorblind_type + " colourblindness:") blind_colors = distinctipy.get_colors(N, colorblind_type=colorblind_type) colorblind.simulate_colors(blind_colors, colorblind_type=colorblind_type) ``` -------------------------------- ### Generate N Distinct Colors Source: https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb Generate a specified number of visually distinct colors. By default, black and white are excluded from the generated palette. This is useful for creating color schemes for data visualization or design. ```python # generate 36 distinct colours (excluding black and white by default) colors = distinctipy.get_colors(36) # display the colours distinctipy.color_swatch(colors) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.