astrohack.visualization.plot_tools
Attributes
Functions
|
Create a figures and plotting axes within according to a desired figure size and number of boxes |
|
Set title, save to disk and optionally close the figure |
|
Adds a well positioned colorbar to a plot |
|
Compute extent from the arrays representing the X and Y axes |
|
|
|
Set limits and axis labels to array configuration boxes |
|
Do scatter simple scatter plots of data to a plotting axis |
|
|
|
Module Contents
- create_figure_and_axes(figure_size: list | tuple | None, boxes: list | tuple | numpy.ndarray, default_figsize: list | tuple = figsize, sharex: bool = False, sharey: bool = False, plot_is_3d: bool = False, force_2d_axes_array: bool = False)[source]
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
- close_figure(figure: matplotlib.figure.Figure, title: str, filename: str, dpi: int, display: bool, tight_layout: bool = True)[source]
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?
- 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)[source]
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
- compute_extent(x_axis: numpy.ndarray, y_axis: numpy.ndarray, margin: float | int = 0.0)[source]
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]
- 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)[source]
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
- 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')[source]
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
- 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')[source]