Resolve "Check color-blind friendly and corporate-design compliant colors for plots"
Add implementation to specify parameters of a color map and fill pattern map
- Add an enum for fill pattern hatches.
- Add an enum for custom colors.
- Add class to create color maps and fill pattern maps.
- Custom color maps can be specified.
- Custom fill pattern maps can be specified.
- Default color map is given,
- Default fill pattern is given.
- Boundary boxes can be displayed for value labels of bars.
- Add matrix plot color map parameter.
- Add box face color parameter.
Description:
The intention for this change was to hand over two ColorMapParameters
objects to configure one colour scheme for the bars and one color scheme for the value labels inside the bars.
Note: There are quite some options to configure your color map, which would bloat the parameter list of the plot function quite a bit if we would pass these parameters directly to the plot function. That's why a new class is introduced that take up all these parameters.
You have the following options:
- Possibility to fill bars with color.
- Possibility to set color map out of a set of predefined color maps.
- Possibility to invert the chosen predefined color map.
- Possibility to add a brightness factor to the colors in the color map.
- Possibility to define your own color map.
- Possibility to define a fill pattern map for color blind people.
Example:
Bar plots expect two ColorMapParameters
objects, in principle, like this:
param_bars = ColorMapParameters(len(df.columns), color_map_name="tab20")
param_labels = ColorMapParameters(len(df.columns), color_map_name="tab20", brightness_factor=0.5)
plot_bar_chart(df, bar_color_map_parameters=param_bars, label_color_map_parameters=param_labels)
Custom color scheme example:
In order to define new color scheme you can add a new Python dictionary to class DefaultColors
like this:
HH10_COLORS: Dict[Custom20Colors, str] = {
Custom20Colors.CUSTOM_01: "#005AA0", # HH_BLUE
Custom20Colors.CUSTOM_02: "#8CB422", # HH_GREEN
Custom20Colors.CUSTOM_03: "#5A696E", # HH_GRAY
Custom20Colors.CUSTOM_04: "#A0235A", # HH_INFO
Custom20Colors.CUSTOM_05: "#FFD228", # HH_ENERGY
Custom20Colors.CUSTOM_06: "#50C8AA", # HH_AERO
Custom20Colors.CUSTOM_07: "#D23264", # HH_HEALTH
Custom20Colors.CUSTOM_08: "#0A2D6E", # HH_DARK
Custom20Colors.CUSTOM_09: "#F0781E", # HH_MATTER
Custom20Colors.CUSTOM_10: "#326469", # HH_EARTH
}
In your script you can then create two instances of ColorMapParameters
and pass it to method hifis_surveyval.plotter.plot_bar_chart()
:
param_bars = ColorMapParameters(len(df.columns), custom_color_map=DefaultColors.HH10_COLORS)
param_labels = ColorMapParameters(len(df.columns), custom_color_map=DefaultColors.HH10_COLORS, brightness_factor=0.5)
hifis_surveyval.plotter.plot_bar_chart(
data_frame=df,
plot_file_name="example",
bar_color_map_parameters=param_bars,
label_color_map_parameters=param_labels)
The resulting plot is the following:
Closes #177 (closed)