piel.visual#
Submodules#
Attributes#
This mapping creates an automatic relationship between the data collection and the plotting required. |
|
Functions#
|
This function is a generic implementation of the savefig functionality in matplotlib, |
|
Plot a simple line graph. This function abstracts the basic plotting functionality |
|
Plot multiple rows of files on separate subplots, sharing the same x-axis. |
|
Plot multiple (x_data, y_data) pairs on separate subplots, similar to plot_simple. |
|
This function creates a figure and a set of axes in this figure according to the number of rows or columns defined. |
|
|
|
|
|
This function creates a list of plots that are separate from each other. |
|
This function takes in the parameter_list and a figure, axes list, to return a figure and axes with an attached |
Inserts tables between vertical subplots in an existing figure. |
|
|
Get all the rows of the dictionary. We want to copy and append a row at a particular index of the dictionary values. |
|
This function converts specific steady-state point files into steady-state lines with a defined transient time in |
Activates the piel fast rc params. |
|
|
TODO signals |
|
|
|
|
|
|
This function will automatically plot the data from the MeasurementDataCollection provided. |
|
|
This function will automatically plot the data from the MeasurementData object provided. |
|
This function will automatically plot the data from the ExperimentData object provided. |
Package Contents#
- save(fig, **kwargs)[source]#
This function is a generic implementation of the savefig functionality in matplotlib, and is used as a wrapper on all :return:
- plot_simple(x_data: numpy.ndarray, y_data: numpy.ndarray, label: str | None = None, ylabel: str | piel.types.Unit | None = None, xlabel: str | piel.types.Unit | None = None, fig: Any | None = None, axs: List[Any] | None = None, title: str | None = None, plot_args: list = None, plot_kwargs: dict = None, figure_kwargs: dict = None, legend_kwargs: dict = None, title_kwargs: dict = None, xlabel_kwargs: dict = None, ylabel_kwargs: dict = None, *args, **kwargs) tuple[source]#
Plot a simple line graph. This function abstracts the basic plotting functionality while keeping the flexibility of the matplotlib library, allowing customization of labels, titles, and figure properties.
- Parameters:
x_data (np.ndarray) – Data for the X-axis.
y_data (np.ndarray) – Data for the Y-axis.
label (Optional[str], optional) – Label for the plot line, useful for legends. Defaults to None.
ylabel (str | Unit | None, optional) – Label for the Y-axis, or a Unit object with a label and base attribute. Defaults to None.
xlabel (str | Unit | None, optional) – Label for the X-axis, or a Unit object with a label and base attribute. Defaults to None.
fig (Optional[Any], optional) – Matplotlib Figure object to be used. Defaults to None.
axs (Optional[List[Any]], optional) – List of Matplotlib Axes objects. Defaults to None.
title (Optional[str], optional) – Title of the plot. Defaults to None.
plot_args (list, optional) – Positional arguments passed to plt.plot(). Defaults to None.
plot_kwargs (dict, optional) – Keyword arguments passed to plt.plot(). Defaults to None.
figure_kwargs (dict, optional) – Keyword arguments for figure creation. Defaults to None.
legend_kwargs (dict, optional) – Keyword arguments for legend customization. Defaults to None.
title_kwargs (dict, optional) – Keyword arguments for title customization. Defaults to None.
xlabel_kwargs (dict, optional) – Keyword arguments for X-axis label customization. If ‘show’ is set to False, the X-axis label will not be displayed. Defaults to None.
ylabel_kwargs (dict, optional) – Keyword arguments for Y-axis label customization. If ‘show’ is set to False, the Y-axis label will not be displayed. Defaults to None.
*args – Additional positional arguments for plt.plot().
**kwargs – Additional keyword arguments for plt.plot().
- Returns:
The figure and axes of the plot.
- Return type:
Tuple[plt.Figure, plt.Axes]
- plot_simple_multi_row(data: pandas.DataFrame, x_axis_column_name: str = 't', row_list: List[str] | None = None, y_label: List[str] | None = None, x_label: str | None = None, titles: List[str] | None = None, subplot_spacing: float = 0.15) Any[source]#
Plot multiple rows of files on separate subplots, sharing the same x-axis.
- Parameters:
data (pd.DataFrame) – Data to plot.
x_axis_column_name (str, optional) – Column name of the x-axis. Defaults to “t”.
row_list (Optional[List[str]], optional) – List of column names to plot. Defaults to None.
y_label (Optional[List[str]], optional) – List of Y-axis titles for each subplot. Defaults to None.
x_label (Optional[str], optional) – Title of the x-axis. Defaults to None.
titles (Optional[List[str]], optional) – Titles for each subplot. Defaults to None.
subplot_spacing (float, optional) – Spacing between subplots. Defaults to 0.3.
- Returns:
The matplotlib figure containing the subplots.
- Return type:
plt.Figure
- plot_simple_multi_row_list(data: list[tuple[numpy.ndarray, numpy.ndarray]], labels: List[str | None] | None = None, y_labels: List[str | None] | None = None, x_label: str | None = None, titles: List[str | None] | None = None, fig: Any | None = None, axs: List[Any] | None = None, plot_args: List[List[Any]] | None = None, plot_kwargs: List[dict[str, Any]] | None = None, figure_kwargs: dict[str, Any] | None = None, legend_kwargs: dict[str, Any] | None = None, title_kwargs: dict[str, Any] | None = None, subplot_spacing: float = 0.15, *args, **kwargs) tuple[Any, List[Any]][source]#
Plot multiple (x_data, y_data) pairs on separate subplots, similar to plot_simple.
- Parameters:
data (List[Tuple[np.ndarray, np.ndarray]]) – List of tuples containing x and y data.
labels (Optional[List[Optional[str]]], optional) – List of labels for each plot. Defaults to None.
y_labels (Optional[List[Optional[str]]], optional) – List of Y-axis labels for each subplot. Defaults to None.
x_label (Optional[str], optional) – Common X-axis label for all subplots. Defaults to None.
titles (Optional[List[Optional[str]]], optional) – List of titles for each subplot. Defaults to None.
fig (Optional[plt.Figure], optional) – Matplotlib figure. If None, a new figure is created. Defaults to None.
axs (Optional[List[plt.Axes]], optional) – List of Matplotlib axes. If None, new axes are created. Defaults to None.
plot_args (Optional[List[List[Any]]], optional) – List of positional arguments for each plot. Defaults to None.
plot_kwargs (Optional[List[dict[str, Any]]], optional) – List of keyword arguments for each plot. Defaults to None.
figure_kwargs (Optional[dict[str, Any]]], optional) – Keyword arguments for figure creation. Defaults to None.
legend_kwargs (Optional[dict[str, Any]]], optional) – Keyword arguments for legends. Defaults to None.
title_kwargs (Optional[dict[str, Any]]], optional) – Keyword arguments for titles. Defaults to None.
subplot_spacing (float, optional) – Spacing between subplots. Defaults to 0.15.
*args – Additional positional arguments passed to plt.plot().
**kwargs – Additional keyword arguments passed to plt.plot().
- Returns:
The figure and list of axes of the plot.
- Return type:
Tuple[plt.Figure, List[plt.Axes]]
- create_axes_per_figure(rows: int = 1, columns: int = 1, **kwargs) tuple[source]#
This function creates a figure and a set of axes in this figure according to the number of rows or columns defined.
- create_plot_containers(container_list: list, axes_structure: piel.visual.types.AxesPlottingTypes = 'separate', **kwargs) tuple[source]#
- list_to_separate_plots(container_list: list, axes_per_element: int = 1, multi_axes_extension_direction: piel.visual.types.ExtensiblePlotsDirectionPerElement = 'x', **kwargs) tuple[source]#
This function creates a list of plots that are separate from each other.
- create_axes_parameters_table_overlay(fig, axs: list, parameters_list: list, font_family='Roboto', header_font_weight='bold', cell_font_size=10, cell_font_weight='normal')[source]#
This function takes in the parameter_list and a figure, axes list, to return a figure and axes with an attached parameter table and relevant colors and line styles. The figure must already have the axes plotted and ready to extract the relevant colors, line styles, and parameters from it accordingly.
This function is particularly useful if the parametric sweep is overlaid in multiple lines of the same axes.
- create_axes_parameters_tables_separate(fig, axs: list, parameter_tables_list: list, table_height=0.15, spacing=0.01) tuple[source]#
Inserts tables between vertical subplots in an existing figure. Adjusts the subplot positions to create space for the tables.
Parameters: - fig: The figure object containing the subplots. - axs: A list of axes objects corresponding to the subplots. - parameter_tables_list: A list containing the data to display in the tables.
Each element can be a DataFrame, Series, or list of lists.
table_height: The height of the tables relative to the figure (default is 0.2).
spacing: Space between the subplots and the tables (default is 0.05).
Returns: - fig: The updated figure object. - axs: The updated list of axes objects, including the tables.
- append_row_to_dict(data: dict, copy_index: int, set_value: dict)[source]#
Get all the rows of the dictionary. We want to copy and append a row at a particular index of the dictionary values. Operates on existing files
- Parameters:
data – Dictionary of files to be appended.
copy_index – Index of the row to be copied.
set_value – Dictionary of values to be set at the copied index.
- Returns:
None
- points_to_lines_fixed_transient(data: pandas.DataFrame, time_index_name: str, fixed_transient_time=1, return_dict: bool = False, ignore_rows: list = None)[source]#
This function converts specific steady-state point files into steady-state lines with a defined transient time in order to plot digital-style files.
For example, VCD files tends to be structured in this form:
#2001 b1001 " b10010 # b1001 ! #4001 b1011 " b1011 # b0 ! #6001 b101 "
This means that even when tokenizing the files, when visualising it in a wave plotter such as GTKWave, the signals get converted from token specific times to transient signals by a corresponding transient rise time. If we want to plot the files correspondingly in Python, it is necessary to add some form of transient signal translation. Note that this operates on a dataframe where the electrical time signals are clearly defined. It copies the corresponding steady-state files points whilst adding files points for the time-index accordingly.
It starts by creating a copy of the initial dataframe as to not overwrite the existing files. We have an initial time files point that tends to start at time 0. This means we need to add a point just before the next steady state point transition. So what we want to do is copy the existing row and just change the time to be the fixed_transient_time before the next transition.
Doesn’t append on penultimate row.
- Parameters:
dataframe – Dataframe or dictionary of files to be converted.
time_index_name – Name of the time index column.
fixed_transient_time – Time of the transient signal.
return_dict – Return a dictionary instead of a dataframe.
ignore_rows – Rows to ignore when converting to steady-state lines.
- Returns:
Dataframe or dictionary of files with steady-state lines.
- primary_cycler = None#
- secondary_cycler = None#
- primary_color_palette = ['#1982C4', '#B79174', '#6B4C93', '#C6B7DA', '#A17500', '#8C564B', '#32490E', '#6A5541',...#
- secondary_color_palette = ['#145B93', '#8D7059', '#50356A', '#978BAA', '#754F00', '#693E36', '#24360A', '#4D3D31',...#
- MultiTimeSignalData#
- AxesPlottingTypes#
- ExtensiblePlotsDirectionPerElement#
- measurement_data_to_plot_map#
This mapping creates an automatic relationship between the data collection and the plotting required.
- measurement_data_collection_to_plot_map#
- measurement_data_collection_to_plot_suffix_map#
- auto_plot_from_measurement_data_collection(measurement_data_collection: piel.types.experimental.MeasurementDataCollectionTypes, plot_output_directory: piel.types.PathTypes = None, extra_plot_output_directories: list[piel.types.PathTypes] = None, measurement_data_collection_to_plot_map: dict = measurement_data_collection_to_plot_map, measurement_data_collection_to_plot_prefix_map: dict = measurement_data_collection_to_plot_suffix_map, **kwargs) tuple[list[tuple], list[piel.types.PathTypes]][source]#
This function will automatically plot the data from the MeasurementDataCollection provided. If there are more than one set of relevant plots for a given MeasurementData, it will generate a list of figures accordingly.
- auto_plot_from_measurement_data(measurement_data: piel.types.experimental.MeasurementDataTypes, **kwargs) list[tuple, piel.types.PathTypes][source]#
This function will automatically plot the data from the MeasurementData object provided. If there are more than one set of relevant plots for a given MeasurementData, it will generate a list of figures accordingly.
- auto_plot_from_experiment_data(experiment_data: piel.types.experimental.ExperimentData, plot_output_directory: piel.types.PathTypes = None, parametric: bool = False, **kwargs) tuple[list[tuple], list[piel.types.PathTypes]][source]#
This function will automatically plot the data from the ExperimentData object provided.