utils¶
The utils module provides functions for standardization including feature coloration and regularization.
Functions
- pltviz.utils.round_if_int(val)[source]¶
Rounds off the decimal of a value if it is an integer float.
- Parameters:
- valfloat or int
A numeric value to be rounded.
- pltviz.utils.gen_list_of_lists(original_list, new_structure)[source]¶
Generates a list of lists with a given structure from a given list.
- Parameters:
- original_listlist
The list to make into a list of lists.
- new_structurelist of lists (contains ints).
- Returns:
- list_of_listslist of lists
The original list with elements organized with the given structure.
- pltviz.utils.add_num_commas(num)[source]¶
Adds commas to a numeric string for readability.
- Parameters:
- numint or float
A number to have commas added to.
- pltviz.utils.hex_to_rgb(hex_rep)[source]¶
Converts a hexadecimal representation to its RGB ratios.
- Parameters:
- hex_repstr
The hex representation of the color.
- Returns:
- rgb_triptuple
An RGB tuple color representation.
- pltviz.utils.rgb_to_hex(rgb_trip)[source]¶
Converts rgb ratios to their hexadecimal representation.
- Parameters:
- rgb_triptuple
An RGB tuple color representation.
- Returns:
- hex_repstr
The hex representation of the color.
- pltviz.utils.scale_saturation(rgb_trip, sat)[source]¶
Changes the saturation of an rgb color.
- Parameters:
- rgb_triptuple
An RGB tuple color representation.
- satfloat
The saturation it rgb_trip should be modified by.
- Returns:
- saturated_rgbtuple
colorsys.hls_to_rgb saturation of the given color.
- pltviz.utils.create_color_palette(start_rgb, end_rgb, num_colors, colorspace)[source]¶
Generates a color palette between two colors.
- Parameters:
- start_rgbcolormath.color_objects.sRGBColor
The first color in the palette.
- end_rgbcolormath.color_objects.sRGBColor
The last color in the palette.
- num_colorsint
The total colors of the palette including the start and end colors.
- colorspacecolormath.color_object
The color scheme for the palette.
- Returns:
- palettelist (contains sts)
A list of length num_colors with color hexes for the palette elements.
- pltviz.utils.gen_random_colors(num_groups, colors=None)[source]¶
Generates random colors.
- Parameters:
- num_groupsint
The number of groups for which colors should be generated.
- colorslistoptional (contains strs)
Hex based colors that should be appended if not enough have been provided.
- Returns:
- colors or colors + new_colorslist (contains strs)
Randomly generated colors for figures and plotting.