hifis_surveyval.plotting package¶
Submodules¶
hifis_surveyval.plotting.matplotlib_color_map_parameters module¶
Module offers functionality to create color maps and fill pattern maps.
- class hifis_surveyval.plotting.matplotlib_color_map_parameters.ColorMapParameters(number_colors_required: Optional[int] = None, use_color: bool = True, use_pattern: bool = False, color_map_name: Optional[str] = None, use_inverted_color_map: bool = False, brightness_factor: float = 1.0, custom_color_map: Dict[enum.Enum, str] = {<CustomColors.CUSTOM_01: 1>: '#99BDD9', <CustomColors.CUSTOM_02: 2>: '#669CC6', <CustomColors.CUSTOM_03: 3>: '#337BB3', <CustomColors.CUSTOM_04: 4>: '#005AA0', <CustomColors.CUSTOM_05: 5>: '#004880', <CustomColors.CUSTOM_06: 6>: '#002D50'}, pattern_map: Dict[enum.Enum, str] = {<FillPattern.PATTERN_01: 1>: '#FFFFFF', <FillPattern.PATTERN_02: 2>: '/', <FillPattern.PATTERN_03: 3>: '//', <FillPattern.PATTERN_04: 4>: '///', <FillPattern.PATTERN_05: 5>: '////', <FillPattern.PATTERN_06: 6>: '#000000'})[source]¶
Bases:
object
Creates a color map and a fill pattern map from parameters.
- __init__(number_colors_required: Optional[int] = None, use_color: bool = True, use_pattern: bool = False, color_map_name: Optional[str] = None, use_inverted_color_map: bool = False, brightness_factor: float = 1.0, custom_color_map: Dict[enum.Enum, str] = {<CustomColors.CUSTOM_01: 1>: '#99BDD9', <CustomColors.CUSTOM_02: 2>: '#669CC6', <CustomColors.CUSTOM_03: 3>: '#337BB3', <CustomColors.CUSTOM_04: 4>: '#005AA0', <CustomColors.CUSTOM_05: 5>: '#004880', <CustomColors.CUSTOM_06: 6>: '#002D50'}, pattern_map: Dict[enum.Enum, str] = {<FillPattern.PATTERN_01: 1>: '#FFFFFF', <FillPattern.PATTERN_02: 2>: '/', <FillPattern.PATTERN_03: 3>: '//', <FillPattern.PATTERN_04: 4>: '///', <FillPattern.PATTERN_05: 5>: '////', <FillPattern.PATTERN_06: 6>: '#000000'}) None [source]¶
Initialize parameters and creates color map and fill pattern map.
- Args:
- number_colors_required (int):
Number to specify how many colors are needed.
- use_color (bool):
Flag to specify whether to fill plot objects with colors.
- use_pattern (bool):
Flag to specify whether to fill plot objects with patterns.
- color_map_name (str):
Name of the color map to use.
- use_inverted_color_map (bool):
Flag to specify whether color map need to be inverted.
- brightness_factor (float):
Number to specify brightness of colors in color map.
- custom_color_map (Dict[CustomColors, str]):
List to specify custom colors in a color map.
- pattern_map (Dict[FillPattern, str]):
Dictionary of FillPattern to hatch pattern string mappings.
- property color_map: <MagicMock name='mock.Colormap' id='140501826328464'>¶
Access color map property.
- create_color_map_and_patterns() None [source]¶
Create a color map and fill pattern map from parameters.
- property pattern_map: List[str]¶
Access fill pattern map property.
- property use_color: bool¶
Access for use color flag.
- property use_pattern: bool¶
Access for use pattern flag.
- class hifis_surveyval.plotting.matplotlib_color_map_parameters.CustomColors(value)[source]¶
Bases:
enum.Enum
Represents different colors in Matplotlib plots.
- CUSTOM_01 = 1¶
- CUSTOM_02 = 2¶
- CUSTOM_03 = 3¶
- CUSTOM_04 = 4¶
- CUSTOM_05 = 5¶
- CUSTOM_06 = 6¶
- class hifis_surveyval.plotting.matplotlib_color_map_parameters.DefaultColors[source]¶
Bases:
object
Defines default colors to be used in plots.
- HELMHOLTZ_BLUE: Dict[hifis_surveyval.plotting.matplotlib_color_map_parameters.CustomColors, str] = {<CustomColors.CUSTOM_01: 1>: '#99BDD9', <CustomColors.CUSTOM_02: 2>: '#669CC6', <CustomColors.CUSTOM_03: 3>: '#337BB3', <CustomColors.CUSTOM_04: 4>: '#005AA0', <CustomColors.CUSTOM_05: 5>: '#004880', <CustomColors.CUSTOM_06: 6>: '#002D50'}¶
- class hifis_surveyval.plotting.matplotlib_color_map_parameters.DefaultFillPattern[source]¶
Bases:
object
Defines a default fill pattern map to be used in plots.
- SLASH_FILL_PATTERN: Dict[hifis_surveyval.plotting.matplotlib_color_map_parameters.FillPattern, str] = {<FillPattern.PATTERN_01: 1>: '#FFFFFF', <FillPattern.PATTERN_02: 2>: '/', <FillPattern.PATTERN_03: 3>: '//', <FillPattern.PATTERN_04: 4>: '///', <FillPattern.PATTERN_05: 5>: '////', <FillPattern.PATTERN_06: 6>: '#000000'}¶
- class hifis_surveyval.plotting.matplotlib_color_map_parameters.FillPattern(value)[source]¶
Bases:
enum.Enum
Represents different fill patterns in Matplotlib plots.
- PATTERN_01 = 1¶
- PATTERN_02 = 2¶
- PATTERN_03 = 3¶
- PATTERN_04 = 4¶
- PATTERN_05 = 5¶
- PATTERN_06 = 6¶
- PATTERN_07 = 7¶
- PATTERN_08 = 8¶
- PATTERN_09 = 9¶
- PATTERN_10 = 10¶
hifis_surveyval.plotting.matplotlib_plotter module¶
This module provides functionality to plot survey data.
This module is called by survey analysis scripts and is a helper module which processes pandas data-frames as input and transforms them into informative plots. The actual plotting is done by utilizing a separate plotting library called matplotlib.
- class hifis_surveyval.plotting.matplotlib_plotter.MatplotlibPlotter(settings: hifis_surveyval.core.settings.Settings)[source]¶
Bases:
hifis_surveyval.plotting.plotter.Plotter
Provides standardized plotting functionalities with matplotlib.
- plot_bar_chart(data_frame: <MagicMock id='140501826821664'>, plot_file_name: str = '', show_legend: bool = True, show_value_labels: bool = True, round_value_labels_to_decimals: int = 0, **kwargs) None [source]¶
Plot given data-frame as a (stacked) bar chart.
A pandas DataFrame is used as input data from which a (stacked) bar chart is generated. This DataFrame need be structured in a particular way. The actual data values are taken column by column and plotted as bars for each index entry. In case of a normal bar chart this means each sequence of bars / column is put next to each other while each sequence is grouped by the series / rows and labeled accordingly in the legend. By contrast in case of a stacked bar chart each sequence of bars / column is stacked on top of the previous instead of put next to each other and labeled accordingly in the legend. The index names are used to label the ticks along the x-axis, while the column names are used as labels in the legend.
- Args:
- data_frame (DataFrame):
All data needed for this function to plot a stacked bar chart is encapsulated in this DataFrame.
- plot_file_name (str):
Optional file name which is used to store the plot to a file. If this argument is an empty string (Default) for this argument, a suitable file name is auto-generated.
- show_legend (bool):
Used to control whether a legend is included in the plot or not. (Default: True)
- show_value_labels (bool):
Enable or disable labels to show the values of each bar. ( Default: True)
- round_value_labels_to_decimals (int):
Round label values to the number of decimals. (Default: 0)
- **kwargs:
- stacked (bool):
Prompts the generation of a stacked bar chart instead on bars being grouped side-by-side.
- plot_title (str):
The title text for the plot. (Default: “”)
- plot_title_fontsize (float):
The font-size of the plot title. (Default: 10)
- x_axis_label (str):
The label for the x-axis. Default: “”)
- x_label_rotation (int):
Allows to rotate the x-axis labels for better readability. Value is given in degrees. (Default: 0)
- y_axis_label (str):
The label for the y-axis. Default: “”)
- legend_location (str):
Specifies positioning of the plot’s legend. (Default: “best”) See Also: pandas.Axis.legend(loc)
- legend_anchor (BboxBase):
Allows to specify an anchor point for the plot’s legend ( Default: None) See Also: pandas.Axis.legend(bbox_to_anchor)
- ylim (Set[float]):
Allows to specify the maximum and minimum values of the y axis (Default: None) See Also: matplotlib.axes.Axes.set_ylim
- figure_size (Tuple[float]):
This tuple indicates the aspect ratio in terms of the figure width and height of an image to plot. (Default: The figure is auto-sized if the figure size is not given.)
- plot_style_name (str):
This indicates which plot style to use.
- bar_color_map_parameters (ColorMapParameters):
Object to initialize the parameters to create the color map for bars.
- label_color_map_parameters (ColorMapParameters):
Object to initialize the parameters to create the color map for value labels of bars.
- plot_box_chart(data_frame: Optional[<MagicMock id='140501826821664'>] = None, data_frames: Optional[List[<MagicMock id='140501826821664'>]] = None, plot_file_name: str = '', **kwargs) None [source]¶
Generate a box chart from the provided data.
Each column in the frame corresponds to one box with whiskers.
- Args:
- data_frame (Optional[DataFrame]):
A singular data frame. Syntactic sugar for using data_frame=x instead of data_frames=[x].
- data_frames (List[DataFrame]):
A list of data frames. The columns with the same column index across all the frames are grouped together.
- plot_file_name (str):
Optional file name which is used to store the plot to a file. If this argument is an empty string (Default) for this argument, a suitable file name is auto-generated.
- **kwargs:
- plot_title (str):
The title text for the plot. (Default: “”)
- x_axis_label (str):
The label for the x-axis. Default: “”)
- x_label_rotation (int):
Allows to rotate the x-axis labels for better readability. Value is given in degrees. (Default: 0)
- y_axis_label (str):
The label for the y-axis. Default: “”)
- figure_size (Tuple[float]):
This tuple indicates the aspect ratio in terms of the figure width and height of an image to plot. (Default: The figure is auto-sized if the figure size is not given.)
- plot_style_name (str):
This indicates which plot style to use.
- box_face_color (str):
Name of face color of boxes. (Default: “wheat”)
- plot_matrix_chart(data_frame: <MagicMock id='140501826821664'>, plot_file_name: str = '', invert_colors: bool = False, value_label_decimals: int = 2, **kwargs) None [source]¶
Plot given data frame as matrix chart.
- Args:
- data_frame (DataFrame):
The data frame to plot.
- plot_file_name (str):
(Optional) The file name stem for the output file.
- invert_colors (bool):
(Optional) Use an inverted color scheme for plotting. This is recommended for plotting data that represents the absence of something. Defaults to False.
- value_label_decimals (int):
Round label values to the number of decimals. (Default: 2)
- **kwargs:
- plot_title (str):
The title text for the plot. (Dafault: “”)
- x_axis_label (str):
The label for the x-axis. Default: “”)
- x_label_rotation (int):
Allows to rotate the x-axis labels for better readability. Value is given in degrees. (Default: 0)
- y_axis_label (str):
The label for the y-axis. Default: “”)
- figure_size (Tuple[float]):
This tuple indicates the aspect ratio in terms of the figure width and height of an image to plot. (Default: The figure is auto-sized if the figure size is not given.)
- plot_style_name (str):
This indicates which plot style to use.
- color_map_name (str):
Name determines the color map selected to fill cells.
- add_value_label_box (bool):
Flag specifies whether to add value label boxes.
hifis_surveyval.plotting.plotter module¶
This module provides a framework for plotters.
- class hifis_surveyval.plotting.plotter.Plotter(settings: hifis_surveyval.core.settings.Settings)[source]¶
Bases:
abc.ABC
Base class to derive plotters from.
- __init__(settings: hifis_surveyval.core.settings.Settings) None [source]¶
Initialize a plotter.
- Args:
- settings: (Settings):
A Settings container to store the setup configuration in. It will be populated with the related settings during the initialization of the HIFISSurveyval object.
hifis_surveyval.plotting.supported_output_format module¶
This module provides a way of handling output formats for plotters.
- class hifis_surveyval.plotting.supported_output_format.SupportedOutputFormat(value)[source]¶
Bases:
enum.Enum
An abstraction of the supported output formats for generated images.
- PDF = 2¶
- PNG = 3¶
- SCREEN = 1¶
- SVG = 4¶
- classmethod from_str(enum_entry: str) enum.Enum [source]¶
Generate an enum object from a string.
- Args:
- enum_entry (str): String to be converted into another string
representing a supported output format.
- Returns:
Enum: Enumeration entry that has been selected.
- Raises:
- NotImplementedError: Exception thrown if output format is not
supported.
Module contents¶
This package provides plotting functionalities.