wolfhece.matplotlib_fig

Module Contents

wolfhece.matplotlib_fig.sanitize_fmt(fmt)[source]

Sanitizes the given format string for numerical formatting. This function ensures that the format string is in a valid format for floating-point number representation. If the input format string is ‘None’ or an empty string, it defaults to ‘.2f’. Otherwise, it ensures that the format string contains a decimal point and ends with ‘f’ for floating-point representation. If the format string is ‘.f’, it defaults to ‘.2f’.

Parameters:

fmt (str) – The format string to be sanitized.

Returns:

A sanitized format string suitable for floating-point number formatting.

Return type:

str

class wolfhece.matplotlib_fig.Matplotlib_ax_properties(ax=None)[source]
property is_equal[source]
reset_selection()[source]
select_line(idx: int)[source]
set_ax(ax: matplotlib.axes.Axes)[source]
_set_props()[source]

Set the properties UI

populate()[source]

Populate the properties UI

ui()[source]
destroyprop()[source]
bounds_lines()[source]
fill_property(verbosity=True)[source]
set_properties(ax: matplotlib.axes.Axes = None)[source]
get_properties(ax: matplotlib.axes.Axes = None)[source]
to_dict() str[source]

properties to dict

from_dict(props: dict, frame: wx.Frame = None)[source]

properties from dict

serialize()[source]

Serialize the properties

deserialize(props: str)[source]

Deserialize the properties

add_props_to_sizer(frame: wx.Frame, sizer: wx.BoxSizer)[source]

Add the properties to a sizer

show_props()[source]

Show the properties

hide_props()[source]

Hide the properties

hide_all_props()[source]

Hide all properties

del_line(idx: int)[source]

Delete a line

wolfhece.matplotlib_fig.MARKERS_MPL = ['None', 'o', 'v', '^', '<', '>', 's', 'p', 'P', '*', 'h', 'H', '+', 'x', 'X', 'D', 'd', '|', '_'][source]
wolfhece.matplotlib_fig.LINESTYLE_MPL = ['-', '--', '-.', ':', 'solid', 'dashed', 'dashdot', 'dotted', 'None'][source]
wolfhece.matplotlib_fig.convert_colorname_rgb(color: str) str[source]

Convert a given color name or abbreviation to its corresponding RGB tuple.

Parameters:

color (str) – The color name or abbreviation to convert. Supported colors are ‘b’/’blue’, ‘g’/’green’, ‘r’/’red’, ‘c’/’cyan’, ‘m’/’magenta’, ‘y’/’yellow’, ‘k’/’black’, ‘w’/’white’, and ‘o’/’orange’.

Returns:

A tuple representing the RGB values of the color. If the color is not recognized, returns (0, 0, 0) which corresponds to black.

Return type:

tuple

wolfhece.matplotlib_fig.convert_color(value: str | tuple) tuple[source]

Convert a hex color to RGB

class wolfhece.matplotlib_fig.Matplolib_line_properties(line: matplotlib.lines.Line2D = None, ax_props: Matplotlib_ax_properties = None)[source]
property ax_props[source]
property ax[source]
property fig[source]
property selected[source]
property linestyle[source]
property marker[source]
copy()[source]
presets(preset: str)[source]

Set the properties to a preset

set_line(line: matplotlib.lines.Line2D)[source]
on_pick(line: matplotlib.lines.Line2D, mouseevent: matplotlib.backend_bases.MouseEvent)[source]
get_properties(line: matplotlib.lines.Line2D = None)[source]
_set_props()[source]

Set the properties UI

populate()[source]

Populate the properties UI

ui()[source]
destroyprop()[source]
fill_property(verbosity: bool = True)[source]
set_properties(line: matplotlib.lines.Line2D = None)[source]
show_properties()[source]
to_dict() str[source]

properties to dict

from_dict(props: dict)[source]

properties from dict

add_props_to_sizer(frame: wx.Frame, sizer: wx.BoxSizer)[source]

Add the properties to a sizer

show_props()[source]

Show the properties

hide_props()[source]

Hide the properties

delete()[source]

Delete the properties

class wolfhece.matplotlib_fig.PRESET_LAYOUTS[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.matplotlib_fig.PRESET_LAYOUTS

Generic enumeration.

Derive from this class to define new enumerations.

DEFAULT = (1, 1)[source]
MAT2X2 = (2, 2)[source]
class wolfhece.matplotlib_fig.Matplotlib_Figure(layout: tuple | list | dict | PRESET_LAYOUTS = None)[source]

Bases: wx.Frame

Inheritance diagram of wolfhece.matplotlib_fig.Matplotlib_Figure

Matplotlib Figure with wx Frame

property layout[source]
property fig_properties: Matplotlib_figure_properties[source]
property _axes_properties: list[Matplotlib_ax_properties][source]
property nbrows[source]
property nbcols[source]
property nb_axes[source]
property cur_ax: matplotlib.axes.Axes[source]
property cur_ax_properties: Matplotlib_ax_properties[source]
property cur_line_properties: Matplolib_line_properties[source]
property cur_line: matplotlib.lines.Line2D[source]
presets(which: PRESET_LAYOUTS = PRESET_LAYOUTS.DEFAULT)[source]

Presets

apply_layout(layout: tuple | list | dict | PRESET_LAYOUTS)[source]

Apply the layout

Choose between (subplots, subplot_mosaic, gridspec) according to the type of layout (tuple, list[str], dict)

set_wx()[source]

Set the wx Frame Design

on_save(event)[source]

Save the figure

on_load(event)[source]

Load the figure

ChangeCursor(event: matplotlib.backend_bases.MouseEvent)[source]
UpdateStatusBar(event: matplotlib.backend_bases.MouseEvent)[source]
_mask_all_axes_props()[source]
_show_axes_props(idx: int)[source]
get_figax()[source]
on_close(event)[source]
on_fig_properties(event)[source]

Show the figure properties

show_fig_properties()[source]
_fill_lines_ax(idx: int = None)[source]
on_ax_choice(event)[source]
on_ax_properties(event)[source]

Show the ax properties

show_curax_properties()[source]
on_line_properties(event)[source]

Show the line properties

show_curline_properties()[source]
onapply_properties(event)[source]

Apply the properties

_hide_all_props()[source]
on_line_choose(event)[source]
on_size(event)[source]

Resize event

update_layout()[source]
on_collaps_pane(event)[source]

Collapsible pane event

OnKeyCanvas(event: matplotlib.backend_bases.KeyEvent)[source]
OnClickCanvas(event: matplotlib.backend_bases.MouseEvent)[source]
fill_grid_with_xy(line: matplotlib.lines.Line2D = None, grid: wolfhece.CpGrid.CpGrid = None, colx: int = 0, coly: int = 1)[source]
update_line_from_grid(event)[source]
add_row_to_grid(event)[source]
onadd_line(event)[source]

Add a plot to the current ax

_get_xy_from_grid(grid: wolfhece.CpGrid.CpGrid, colx: int = 0, coly: int = 1)[source]

Get the xy from a grid

add_line(xy: numpy.ndarray, ax: matplotlib.axes.Axes = None, **kwargs)[source]

Add a plot to the current ax

ondel_line(event)[source]

Remove a plot from the current ax

del_line(idx: int)[source]

Delete a line

get_ax_idx(key: str | int | matplotlib.axes.Axes = None) matplotlib.axes.Axes[source]
plot(x: numpy.ndarray, y: numpy.ndarray, ax: matplotlib.axes.Axes | int | str = None, **kwargs)[source]
to_dict() dict[source]

properties to dict

from_dict(props: dict)[source]

properties from dict

serialize()[source]

Serialize the properties

deserialize(props: str)[source]

Deserialize the properties

save(filename: str)[source]
load(filename: str)[source]
save_image(filename: str, dpi: int = 100)[source]
set_x_bounds(xmin: float, xmax: float, ax: matplotlib.axes.Axes | int | str = None)[source]
set_y_bounds(ymin: float, ymax: float, ax: matplotlib.axes.Axes | int | str = None)[source]
class wolfhece.matplotlib_fig.Matplotlib_figure_properties(parent: Matplotlib_Figure = None, fig: matplotlib.figure.Figure = None)[source]
set_fig(fig: matplotlib.figure.Figure)[source]
_set_props()[source]

Set the properties UI

populate()[source]

Populate the properties UI

ui()[source]

Create the properties UI

destroyprop()[source]
fill_property()[source]
set_properties(fig: matplotlib.figure.Figure = None)[source]
get_properties(fig: matplotlib.figure.Figure = None)[source]
to_dict() str[source]

properties to dict

from_dict(props: dict)[source]

properties from dict

add_props_to_sizer(frame: wx.Frame, sizer: wx.BoxSizer)[source]

Add the properties to a sizer

show_props()[source]

Show the properties

hide_props()[source]

Hide the properties

wolfhece.matplotlib_fig.COLORS_MPL = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w', 'blue', 'green', 'red', 'cyan', 'magenta', 'yellow',...[source]