astrohack.visualization.plot_tools ================================== .. py:module:: astrohack.visualization.plot_tools Attributes ---------- .. autoapisummary:: astrohack.visualization.plot_tools.astrohack_cmaps Functions --------- .. autoapisummary:: astrohack.visualization.plot_tools.get_execution_environment astrohack.visualization.plot_tools.create_figure_and_axes astrohack.visualization.plot_tools.close_figure astrohack.visualization.plot_tools.well_positioned_colorbar astrohack.visualization.plot_tools.compute_extent astrohack.visualization.plot_tools.get_proper_color_map astrohack.visualization.plot_tools.plot_boxes_limits_and_labels astrohack.visualization.plot_tools.scatter_plot astrohack.visualization.plot_tools.simple_imshow_map_plot astrohack.visualization.plot_tools.set_y_axis_lims_from_default Module Contents --------------- .. py:data:: astrohack_cmaps .. py:function:: get_execution_environment() .. py:function:: create_figure_and_axes(figure_size: Union[list, tuple, None], boxes: Union[list, tuple, numpy.ndarray], default_figsize: Union[list, tuple] = figsize, sharex: bool = False, sharey: bool = False, plot_is_3d: bool = False, force_2d_axes_array: bool = False) Create a figures and plotting axes within according to a desired figure size and number of boxes :param figure_size: Desired figure size in inches :param boxes: How many subplots in the horizontal and vertical directions :param default_figsize: Default figure size for when the user specifies no figure size :param sharex: Subplots share the X axis :param sharey: Subplots share the Y axis :param plot_is_3d: Subplots will contain 3d data. :param force_2d_axes_array: Returns: Figure and plotting axes array .. py:function:: close_figure(figure: matplotlib.figure.Figure, title: str, filename: str, dpi: int, display: bool, tight_layout: bool = True) Set title, save to disk and optionally close the figure :param figure: The matplotlib figure object :param title: The superior title to be added to the figures :param filename: The file name to which save the figure :param dpi: dots per inch (resolution) :param display: Keep the plotting window open? :param tight_layout: Plots in the figure are tightly packed? .. py:function:: well_positioned_colorbar(ax: matplotlib.axes.Axes, fig: matplotlib.figure.Figure, mappable, label: str, location: str = 'right', size: str = '5%', pad: float | int = 0.05) Adds a well positioned colorbar to a plot :param ax: Axes instance to add the colorbar :param fig: Figure in which the axes are embedded :param mappable: The plt.imshow or colormap instance associated to the colorbar :param label: Colorbar label :param location: Colorbar location :param size: Colorbar size :param pad: Colorbar padding Returns: the well positioned colorbar .. py:function:: compute_extent(x_axis: numpy.ndarray, y_axis: numpy.ndarray, margin: float | int = 0.0) Compute extent from the arrays representing the X and Y axes :param x_axis: X axis np array :param y_axis: Y axis np array :param margin: Optional margin to add to plots :returns: len=4 list with [xmin, xmax, ymin, ymax] .. py:function:: get_proper_color_map(user_cmap: str | None, default_cmap: str = 'viridis') .. py:function:: plot_boxes_limits_and_labels(outerax: matplotlib.axes.Axes, innerax: matplotlib.axes.Axes, xlabel: str, ylabel: str, box_size: float | int, outertitle: str, innertitle: str, marker: str = 'x', marker_color: str = 'blue', rectangle_color: str = 'red', fixed_aspect: float | int | None = None) Set limits and axis labels to array configuration boxes :param fixed_aspect (): :param outerax: Plotting axis for the outer array box :param innerax: Plotting axis for the inner array box :param xlabel: X axis label :param ylabel: Y axis label :param box_size: inner array box size :param outertitle: Title for the outer array box :param innertitle: Title for the inner array box :param marker: Marker for the array center :param marker_color: Color for the array center marker :param rectangle_color: Color of the rectangle representing the inner array box in the outer array plot .. py:function:: scatter_plot(ax: matplotlib.axes.Axes, xdata: numpy.ndarray, xlabel: str, ydata: numpy.ndarray, ylabel: str, title: str | None = None, labels: list | tuple | None = None, xlim: list | tuple | None = None, ylim: list | tuple | None = None, hlines: list | tuple | numpy.ndarray | None = None, vlines: list | tuple | numpy.ndarray | None = None, model: numpy.ndarray | None = None, data_marker: str = '+', data_color: str = 'red', data_linestyle: str = '', data_label: str = 'data', hv_linestyle: str = '--', hv_color: str = 'black', model_marker: str = 'x', model_color: str = 'blue', model_linestyle: str = '', model_label: str = 'model', plot_residuals: bool = True, residuals_marker: str = '+', residuals_color: str = 'black', residuals_linestyle: str = '', residuals_label: str = 'residuals', add_regression: bool = False, regression_linestyle: str = '-', regression_color: str = 'black', regression_method: str = 'linregress', add_regression_reference: bool = False, regression_reference: Any = (1.0, 0.0), regression_reference_color: str = 'orange', regression_reference_label: str = 'Regression refrence', force_equal_aspect: bool = False, add_legend: bool = True, legend_location: str = 'best') Do scatter simple scatter plots of data to a plotting axis :param ax: The plotting axis :param xdata: X axis data :param xlabel: X axis data label :param ydata: Y axis data :param ylabel: Y axis datal label :param title: Plotting axis title :param labels: labels to be added to data :param xlim: X axis limits :param ylim: Y axis limits :param hlines: Horizontal lines to be drawn :param vlines: Vertical lines to be drawn :param model: Model to be overplotted to the data :param data_marker: Marker for data points :param data_color: Color of the data marker :param data_linestyle: Line style for connecting data points :param data_label: Label for data points when displayed along a model :param hv_linestyle: Line style for the horizontal or vertical lines displayed in the plot :param hv_color: Line color for the horizontal or vertical lines displayed in the plot :param model_marker: Marker for the model points :param model_color: Color of the model marker :param model_linestyle: Line style for connecting model points :param model_label: Label for model points :param plot_residuals: Add a residuals subplot at the bottom when a model is provided :param residuals_marker: Marker for residuals :param residuals_color: Color for residual markers :param residuals_linestyle: Line style for residuals :param residuals_label: Label for residuals :param add_regression: Add a linear regression between X and y data :param regression_linestyle: Line style for the regression plot :param regression_color: Color for the regression plot :param regression_method: Which scipy function to use for the linear regression: linregress, theilslopes or siegelslopes :param add_regression_reference: Add reference for the expected regression result :param regression_reference: 2 value array/tuple/list with a slope and intercept for reference :param regression_reference_color: Color for reference regression :param regression_reference_label: Label for reference regression :param force_equal_aspect: Force equal aspect on plot box :param add_legend: add legend to the plot :param legend_location: Location of the legend in the plot .. py:function:: simple_imshow_map_plot(ax: matplotlib.axes.Axes, fig: matplotlib.figure.Figure, x_axis: numpy.ndarray, y_axis: numpy.ndarray, gridded_2d_arr: numpy.ndarray, title: str, colormap: str, zlim: list | tuple | numpy.ndarray, x_label: str = 'X axis [m]', y_label: str = 'Y axis [m]', z_label: str = 'Z Scale', transpose: bool = False, extent: list | tuple | numpy.ndarray | None = None, extent_margin: float | int = 0, add_colorbar: bool = True, interpolation: str = 'nearest') .. py:function:: set_y_axis_lims_from_default(ax: matplotlib.axes.Axes, user_y_scale: tuple | list, prog_defaults: tuple | list)