:py:mod:`wolfhece.matplotlib_fig` ================================= .. py:module:: wolfhece.matplotlib_fig Module Contents --------------- .. py:function:: sanitize_fmt(fmt) 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'. :param fmt: The format string to be sanitized. :type fmt: str :return: A sanitized format string suitable for floating-point number formatting. :rtype: str .. py:class:: Matplotlib_ax_properties(ax: matplotlib.axes.Axes = None) .. py:property:: is_equal .. py:method:: reset_selection() .. py:method:: select_line(idx: int) .. py:method:: set_ax(ax: matplotlib.axes.Axes) .. py:method:: _set_props() Set the properties UI .. py:method:: populate() Populate the properties UI .. py:method:: ui() .. py:method:: destroyprop() .. py:method:: bounds_lines() .. py:method:: fill_property(verbosity=True) .. py:method:: set_properties(ax: matplotlib.axes.Axes = None) .. py:method:: get_properties(ax: matplotlib.axes.Axes = None) .. py:method:: to_dict() -> str properties to dict .. py:method:: from_dict(props: dict, frame: wx.Frame = None) properties from dict .. py:method:: serialize() Serialize the properties .. py:method:: deserialize(props: str) Deserialize the properties .. py:method:: add_props_to_sizer(frame: wx.Frame, sizer: wx.BoxSizer) Add the properties to a sizer .. py:method:: show_props() Show the properties .. py:method:: hide_props() Hide the properties .. py:method:: hide_all_props() Hide all properties .. py:method:: del_line(idx: int) Delete a line .. py:data:: MARKERS_MPL :value: ['None', 'o', 'v', '^', '<', '>', 's', 'p', 'P', '*', 'h', 'H', '+', 'x', 'X', 'D', 'd', '|', '_'] .. py:data:: LINESTYLE_MPL :value: ['-', '--', '-.', ':', 'solid', 'dashed', 'dashdot', 'dotted', 'None'] .. py:function:: convert_colorname_rgb(color: str) -> str Convert a given color name or abbreviation to its corresponding RGB tuple. :param color: 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'. :type color: str :return: A tuple representing the RGB values of the color. If the color is not recognized, returns (0, 0, 0) which corresponds to black. :rtype: tuple .. py:function:: convert_color(value: str | tuple) -> tuple Convert a hex color to RGB .. py:class:: Matplolib_line_properties(line: matplotlib.lines.Line2D = None, ax_props: Matplotlib_ax_properties = None) .. py:property:: xdata .. py:property:: ydata .. py:property:: xydata .. py:property:: ax_props .. py:property:: ax .. py:property:: fig .. py:property:: selected .. py:property:: linestyle .. py:property:: marker .. py:property:: has_world_transfer .. py:property:: xscale .. py:property:: yscale .. py:property:: xorigin_world .. py:property:: yorigin_world .. py:property:: xorigin_local .. py:property:: yorigin_local .. py:method:: get_xydata(two_columns: bool = False) Get the xy data .. py:method:: set_xydata(xy_data: numpy.ndarray) Set the xy data .. py:method:: copy() .. py:method:: presets(preset: str) Set the properties to a preset .. py:method:: set_line(line: matplotlib.lines.Line2D) .. py:method:: on_pick(line: matplotlib.lines.Line2D, mouseevent: matplotlib.backend_bases.MouseEvent) .. py:method:: get_properties(line: matplotlib.lines.Line2D = None) .. py:method:: _set_props() Set the properties UI .. py:method:: populate() Populate the properties UI .. py:method:: ui() .. py:method:: destroyprop() .. py:method:: fill_property(verbosity: bool = True) .. py:method:: set_properties(line: matplotlib.lines.Line2D = None) .. py:method:: show_properties() .. py:method:: to_dict() -> str properties to dict .. py:method:: from_dict(props: dict) properties from dict .. py:method:: add_props_to_sizer(frame: wx.Frame, sizer: wx.BoxSizer) Add the properties to a sizer .. py:method:: show_props() Show the properties .. py:method:: hide_props() Hide the properties .. py:method:: delete() Delete the properties .. py:class:: PRESET_LAYOUTS Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.matplotlib_fig.PRESET_LAYOUTS :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: DEFAULT :value: (1, 1, 'auto') .. py:attribute:: MAT2X2 :value: (2, 2, 'auto') .. py:attribute:: DEFAULT_EQUAL :value: (1, 1, 'equal') .. py:class:: Matplotlib_Figure(layout: tuple | list | dict | PRESET_LAYOUTS = None) Bases: :py:obj:`wx.Frame` .. autoapi-inheritance-diagram:: wolfhece.matplotlib_fig.Matplotlib_Figure :parts: 1 :private-bases: Matplotlib Figure with wx Frame .. py:property:: action .. py:property:: layout .. py:property:: fig_properties :type: Matplotlib_figure_properties .. py:property:: _axes_properties :type: list[Matplotlib_ax_properties] .. py:property:: nbrows .. py:property:: nbcols .. py:property:: nb_axes .. py:property:: cur_ax :type: matplotlib.axes.Axes .. py:property:: cur_ax_properties :type: Matplotlib_ax_properties .. py:property:: cur_line_properties :type: Matplolib_line_properties .. py:property:: cur_line :type: matplotlib.lines.Line2D .. py:method:: presets(which: PRESET_LAYOUTS = PRESET_LAYOUTS.DEFAULT) Presets .. py:method:: apply_layout(layout: tuple | list | dict | PRESET_LAYOUTS) Apply the layout Choose between (subplots, subplot_mosaic, gridspec) according to the type of layout (tuple, list[str], dict) .. py:method:: set_wx() Set the wx Frame Design .. py:method:: on_save(event) Save the figure .. py:method:: on_load(event) Load the figure .. py:method:: ChangeCursor(event: matplotlib.backend_bases.MouseEvent) .. py:method:: UpdateStatusBar(event: matplotlib.backend_bases.MouseEvent) .. py:method:: _mask_all_axes_props() .. py:method:: _show_axes_props(idx: int) .. py:method:: get_figax() .. py:method:: on_close(event) .. py:method:: on_fig_properties(event) Show the figure properties .. py:method:: show_fig_properties() .. py:method:: _fill_lines_ax(idx: int = None) .. py:method:: on_ax_choice(event) .. py:method:: on_ax_properties(event) Show the ax properties .. py:method:: show_curax_properties() .. py:method:: on_line_properties(event) Show the line properties .. py:method:: show_curline_properties() .. py:method:: onapply_properties(event) Apply the properties .. py:method:: _hide_all_props() .. py:method:: on_line_choose(event) .. py:method:: on_size(event) Resize event .. py:method:: update_layout() .. py:method:: on_collaps_pane(event) Collapsible pane event .. py:method:: OnKeyCanvas(event: matplotlib.backend_bases.KeyEvent) .. py:method:: OnKeyRelease(event: matplotlib.backend_bases.KeyEvent) .. py:method:: OnClickCanvas(event: matplotlib.backend_bases.MouseEvent) .. py:method:: fill_grid_with_xy(line: matplotlib.lines.Line2D = None, grid: wolfhece.CpGrid.CpGrid = None, colx: int = 0, coly: int = 1) .. py:method:: fill_grid_with_xy_np(xy: numpy.ndarray, grid: wolfhece.CpGrid.CpGrid = None, colx: int = 0, coly: int = 1) .. py:method:: get_xy_from_grid() Get the xy from the grid .. py:method:: update_line_from_grid(event) .. py:method:: add_row_to_grid(event) .. py:method:: onadd_line(event) Add a plot to the current ax .. py:method:: onnew_line(event) Add a plot to the current ax .. py:method:: new_line(ax: matplotlib.axes.Axes = None, **kwargs) -> Matplolib_line_properties Add a plot to the current ax .. py:method:: _get_xy_from_grid(grid: wolfhece.CpGrid.CpGrid, colx: int = 0, coly: int = 1) Get the xy from a grid .. py:method:: add_line(xy: numpy.ndarray, ax: matplotlib.axes.Axes = None, **kwargs) -> Matplolib_line_properties Add a plot to the current ax .. py:method:: add_image(image: numpy.ndarray | str, ax: matplotlib.axes.Axes = None, **kwargs) .. py:method:: ondel_line(event) Remove a plot from the current ax .. py:method:: del_line(idx: int) Delete a line .. py:method:: get_ax_idx(key: str | int | matplotlib.axes.Axes = None) -> matplotlib.axes.Axes .. py:method:: plot(x: numpy.ndarray, y: numpy.ndarray, ax: matplotlib.axes.Axes | int | str = None, **kwargs) Plot x, y on the current ax or on the ax specified :param x: x values :param y: y values :param ax: ax to plot on :param kwargs: kwargs for the plot (same as matplotlib.pyplot.plot) .. py:method:: scatter(x: numpy.ndarray, y: numpy.ndarray, ax: matplotlib.axes.Axes | int | str = None, **kwargs) Scatter Plot x, y on the current ax or on the ax specified :param x: x values :param y: y values :param ax: ax to plot on :param kwargs: kwargs for the plot (same as matplotlib.pyplot.plot) .. py:method:: violinplot(dataset: numpy.ndarray, position: numpy.ndarray = None, ax: matplotlib.axes.Axes | int | str = None, **kwargs) Plot x, y on the current ax or on the ax specified :param x: x values :param y: y values :param ax: ax to plot on :param kwargs: kwargs for the plot (same as matplotlib.pyplot.plot) .. py:method:: to_dict() -> dict properties to dict .. py:method:: from_dict(props: dict) properties from dict .. py:method:: serialize() Serialize the properties .. py:method:: deserialize(props: str) Deserialize the properties .. py:method:: save(filename: str) .. py:method:: load(filename: str) .. py:method:: save_image(filename: str, dpi: int = 100) .. py:method:: set_x_bounds(xmin: float, xmax: float, ax: matplotlib.axes.Axes | int | str = None) .. py:method:: set_y_bounds(ymin: float, ymax: float, ax: matplotlib.axes.Axes | int | str = None) .. py:class:: Matplotlib_figure_properties(parent: Matplotlib_Figure = None, fig: matplotlib.figure.Figure = None) .. py:method:: set_fig(fig: matplotlib.figure.Figure) .. py:method:: _set_props() Set the properties UI .. py:method:: populate() Populate the properties UI .. py:method:: ui() Create the properties UI .. py:method:: destroyprop() .. py:method:: fill_property() .. py:method:: set_properties(fig: matplotlib.figure.Figure = None) .. py:method:: get_properties(fig: matplotlib.figure.Figure = None) .. py:method:: to_dict() -> str properties to dict .. py:method:: from_dict(props: dict) properties from dict .. py:method:: add_props_to_sizer(frame: wx.Frame, sizer: wx.BoxSizer) Add the properties to a sizer .. py:method:: show_props() Show the properties .. py:method:: hide_props() Hide the properties .. py:data:: COLORS_MPL :value: ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w', 'blue', 'green', 'red', 'cyan', 'magenta', 'yellow',...