evomap.printer
==============

.. py:module:: evomap.printer

.. autoapi-nested-parse::

   Functions to draw maps.



Attributes
----------

.. autoapisummary::

   evomap.printer.DEFAULT_BUBBLE_SIZE
   evomap.printer.DEFAULT_FONT_SIZE
   evomap.printer.title_fontdict_large
   evomap.printer.title_fontdict
   evomap.printer.text_fontdict
   evomap.printer.axis_label_fontdict


Functions
---------

.. autoapisummary::

   evomap.printer.format_tick_labels
   evomap.printer.init_params
   evomap.printer.style_axes
   evomap.printer.set_equal_ticks
   evomap.printer.draw_map
   evomap.printer.normalize_dhat
   evomap.printer.draw_shepard_diagram
   evomap.printer.validate_inputs
   evomap.printer.prepare_transparencies
   evomap.printer.draw_dynamic_map
   evomap.printer.plot_data
   evomap.printer.draw_trajectories
   evomap.printer.fit_attribute
   evomap.printer.fit_attributes
   evomap.printer.draw_map_sequence


Module Contents
---------------

.. py:data:: DEFAULT_BUBBLE_SIZE
   :value: 50


.. py:data:: DEFAULT_FONT_SIZE
   :value: 12


.. py:data:: title_fontdict_large

.. py:data:: title_fontdict

.. py:data:: text_fontdict

.. py:data:: axis_label_fontdict

.. py:function:: format_tick_labels(x, pos)

.. py:function:: init_params(custom_params=None)

   Initialize plot aesthetics.


.. py:function:: style_axes(ax, show_axes=True, show_box=True, show_grid=False, axes_at_origin=False)

.. py:function:: set_equal_ticks(ax)

.. py:function:: draw_map(X, label=None, color=None, size=None, inclusions=None, zoom_on_cluster=None, highlighted_labels=None, show_box=True, show_grid=False, show_axes=True, axes_at_origin=False, show_legend=False, cmap=None, filename=None, ax=None, fig_size=None, title=None, rotate_labels=0, scatter_kws={}, fontdict=None, rcparams=None)

   Plot a scatter map with optional labels, coloring, and sizing.

   :param X: Data points to plot. n_features should be 1 or 2.
   :type X: array-like of shape (n_samples, n_features)
   :param label: Labels for each data point.
   :type label: array-like, optional
   :param color: Colors or group identifiers for each data point. If None, all points will have the same color.
   :type color: array-like, optional
   :param size: Sizes for each data point. If None, a default size is used.
   :type size: array-like, optional
   :param inclusions: Boolean array to select which points are included in the plot.
   :type inclusions: array-like of bool, optional
   :param zoom_on_cluster: Cluster identifier to zoom in on specific cluster data points.
   :type zoom_on_cluster: int or string, optional
   :param highlighted_labels: Labels to be highlighted on the plot.
   :type highlighted_labels: list, optional
   :param show_box: If True, show a box around the plot. Default is True.
   :type show_box: bool, optional
   :param show_grid: If True, show grid lines on the plot. Default is False.
   :type show_grid: bool, optional
   :param show_axes: If True, show the axes of the plot. Default is False.
   :type show_axes: bool, optional
   :param axes_at_origin: If True, draw axes lines through the origin. Default is False.
   :type axes_at_origin: bool, optional
   :param show_legend: If True, display a legend on the plot. Default is False.
   :type show_legend: bool, optional
   :param cmap: Colormap to use for coloring the points. If None, a default colormap is used.
   :type cmap: str or Colormap, optional
   :param filename: Path to save the figure file. If None, the figure is not saved.
   :type filename: str, optional
   :param ax: Pre-existing axes for the plot. If None, a new figure and axes are created.
   :type ax: matplotlib.axes.Axes, optional
   :param fig_size: Size of the figure to create. Ignored if `ax` is not None.
   :type fig_size: tuple, optional
   :param title: Title of the plot.
   :type title: str, optional
   :param rotate_labels: Angle to rotate the labels. Default is 0.
   :type rotate_labels: int, optional
   :param scatter_kws: Additional keyword arguments to pass to the scatter plot function.
   :type scatter_kws: dict, optional
   :param fontdict: Font dictionary for the labels. If None, a default fontdict is used.
   :type fontdict: dict, optional
   :param rcparams: Dictionary to update matplotlib's rcParams for customizing plots.
   :type rcparams: dict, optional

   :returns: Only if `ax` is None, the figure containing the plot is returned.
   :rtype: matplotlib.figure.Figure


.. py:function:: normalize_dhat(d_hat, n_samples)

   Normalize dissimilarity predictions.


.. py:function:: draw_shepard_diagram(X, D, ax=None, show_grid=False, show_rank_correlation=True)

   Draw a Shepard diagram of input dissimilarities vs map distances.

   Parameters:
   X (np.ndarray): Configuration of objects on the map, shape (n_samples, n_dims).
   D (np.ndarray): Dissimilarity matrix, shape (n_samples, n_samples).
   ax (matplotlib.axes.Axes, optional): Axes object to draw the diagram on.
   show_grid (bool, optional): Whether to show grid lines on the plot.
   show_rank_correlation (bool, optional): Whether to display the rank correlation coefficient.


.. py:function:: validate_inputs(X_t, color_t, incl_t, n_samples)

   Validate the shape and consistency of inputs.


.. py:function:: prepare_transparencies(n_periods, start, end, final)

   Prepare transparency values for the plotting periods.


.. py:function:: draw_dynamic_map(X_t, color_t=None, size_t=None, incl_t=None, label=None, show_arrows=False, show_last_positions_only=False, time_labels=None, show_axes=True, show_box=True, axes_at_origin=False, show_grid=False, cmap=None, transparency_start=0.1, transparency_end=0.4, transparency_final=0.75, scatter_kws={}, **kwargs)

   Visualizes dynamic map data over multiple periods with options to show movement paths and adjust visual features.

   :param X_t: List of arrays containing coordinates for each period, where each array is of shape (n_samples, n_features).
   :type X_t: list of ndarray
   :param color_t: List of arrays containing color or group identifiers for each period.
   :type color_t: list of ndarray, optional
   :param size_t: List of arrays containing sizes for each data point in each period.
   :type size_t: list of ndarray, optional
   :param incl_t: List of arrays indicating if a point should be included in the plot for each period.
   :type incl_t: list of ndarray, optional
   :param show_arrows: If True, display arrows showing movement between periods. Default is False.
   :type show_arrows: bool, optional
   :param show_last_positions_only: If True, only the last period's positions are shown with arrows indicating the movements from prior periods. Default is False.
   :type show_last_positions_only: bool, optional
   :param time_labels: Labels for each period, displayed in plot annotations or titles.
   :type time_labels: list of str, optional
   :param transparency_start: Starting transparency level for the first period in the dynamic map.
   :type transparency_start: float, optional
   :param transparency_end: Ending transparency level just before the last period in the dynamic map.
   :type transparency_end: float, optional
   :param transparency_final: Transparency level for the last period in the dynamic map.
   :type transparency_final: float, optional
   :param \*\*kwargs: Additional keyword arguments to pass to the plotting function or for configuring plot aspects.
   :type \*\*kwargs: dict

   :returns: The figure containing the dynamic map, only if not plotted on an existing axis.
   :rtype: matplotlib.figure.Figure


.. py:function:: plot_data(X, colors, sizes, inclusions, labels, transparency_start, transparency_end, transparency_final, period, n_periods, ax, show_last_positions_only)

   Helper function to manage data plotting for each period.


.. py:function:: draw_trajectories(Y_ts, labels, selected_labels=None, show_axes=False, show_box=True, show_grid=False, axes_at_origin=False, annotate_periods=True, period_labels=None, fig_size=None, **kwargs)

   Draw the trajectories of selected objects.

   :param Y_ts: Sequence of map coordinates.
   :type Y_ts: list of ndarrays, each of shape (n_samples, d)
   :param labels: Object labels (str)
   :type labels: ndarray of shape (n_samples,)
   :param selected_labels: Selected object labels (str), by default None
   :type selected_labels: ndarray of shape (n_selected,), optional
   :param title: Figure title, by default None
   :type title: str, optional
   :param annotate_periods: If true, labels for each period are shown next to each pair of map
                            coordinates, by default True
   :type annotate_periods: bool, optional
   :param period_labels: Period labels (str), by default None
   :type period_labels: ndarray of shape (n_periods,), optional
   :param ax: Pre-existing axes for the plot, by default None
   :type ax: matplotlib.axes.Axes, optional
   :param figsize: Figure size, by default (12,12)
   :type figsize: tuple, optional


.. py:function:: fit_attribute(coords, attribute_label, attribute_values, ax, coord_range)

   Fit an attribute to the map and display the resultant vector.


.. py:function:: fit_attributes(map_coords, df_attributes, ax)

   Fit multiple attributes and display their vectors on the map.


.. py:function:: draw_map_sequence(X_t, color_t=None, size_t=None, incl_t=None, n_cols=4, time_labels=[], show_axes=True, show_box=True, axes_at_origin=False, show_grid=False, cmap=None, fontdict=None, scatter_kws={}, **kwargs)

   Draw a sequence of static maps next to each other.

   :param X_t: List of arrays containing map coordinates for each period.
   :type X_t: list of ndarray
   :param color_t: Color for each data point per period.
   :type color_t: list of ndarray, optional
   :param size_t: Size for each data point per period.
   :type size_t: list of ndarray, optional
   :param incl_t: Inclusion array to filter points for each period.
   :type incl_t: list of ndarray, optional
   :param n_cols: Maximum number of maps shown in one row.
   :type n_cols: int, optional
   :param time_labels: Labels for each period, displayed as titles.
   :type time_labels: list of str, optional
   :param show_axes: Show axes of the plot.
   :type show_axes: bool, optional
   :param show_box: Show a box around the plot.
   :type show_box: bool, optional
   :param axes_at_origin: Draw axes lines through the origin.
   :type axes_at_origin: bool, optional
   :param show_grid: Show grid lines on the plot.
   :type show_grid: bool, optional
   :param cmap: Colormap to use for coloring the points.
   :type cmap: str or Colormap, optional
   :param fontdict: Font dictionary for the labels.
   :type fontdict: dict, optional
   :param scatter_kws: Additional keyword arguments to pass to the scatter plot function.
   :type scatter_kws: dict, optional
   :param \*\*kwargs: Additional keyword arguments for figure creation and styling.
   :type \*\*kwargs: dict

   :returns: The figure containing the sequence of maps.
   :rtype: matplotlib.figure.Figure


