evomap.printer#
Functions to draw maps.
Module Contents#
Functions#
|
|
|
Initialize plot aesthetics. |
|
|
|
|
|
Plot a scatter map with optional labels, coloring, and sizing. |
|
Normalize dissimilarity predictions. |
|
Draw a Shepard diagram of input dissimilarities vs map distances. |
|
Validate the shape and consistency of inputs. |
|
Prepare transparency values for the plotting periods. |
|
Visualizes dynamic map data over multiple periods with options to show movement paths and adjust visual features. |
|
Helper function to manage data plotting for each period. |
|
Draw the trajectories of selected objects. |
|
Fit an attribute to the map and display the resultant vector. |
|
Fit multiple attributes and display their vectors on the map. |
|
Draw a sequence of static maps next to each other. |
Attributes#
- evomap.printer.DEFAULT_BUBBLE_SIZE = 50#
- evomap.printer.DEFAULT_FONT_SIZE = 12#
- evomap.printer.title_fontdict_large#
- evomap.printer.title_fontdict#
- evomap.printer.text_fontdict#
- evomap.printer.axis_label_fontdict#
- evomap.printer.style_axes(ax, show_axes=True, show_box=True, show_grid=False, axes_at_origin=False)[source]#
- evomap.printer.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)[source]#
Plot a scatter map with optional labels, coloring, and sizing.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Data points to plot. n_features should be 1 or 2.
label (array-like, optional) – Labels for each data point.
color (array-like, optional) – Colors or group identifiers for each data point. If None, all points will have the same color.
size (array-like, optional) – Sizes for each data point. If None, a default size is used.
inclusions (array-like of bool, optional) – Boolean array to select which points are included in the plot.
zoom_on_cluster (int or string, optional) – Cluster identifier to zoom in on specific cluster data points.
highlighted_labels (list, optional) – Labels to be highlighted on the plot.
show_box (bool, optional) – If True, show a box around the plot. Default is True.
show_grid (bool, optional) – If True, show grid lines on the plot. Default is False.
show_axes (bool, optional) – If True, show the axes of the plot. Default is False.
axes_at_origin (bool, optional) – If True, draw axes lines through the origin. Default is False.
show_legend (bool, optional) – If True, display a legend on the plot. Default is False.
cmap (str or Colormap, optional) – Colormap to use for coloring the points. If None, a default colormap is used.
filename (str, optional) – Path to save the figure file. If None, the figure is not saved.
ax (matplotlib.axes.Axes, optional) – Pre-existing axes for the plot. If None, a new figure and axes are created.
fig_size (tuple, optional) – Size of the figure to create. Ignored if ax is not None.
title (str, optional) – Title of the plot.
rotate_labels (int, optional) – Angle to rotate the labels. Default is 0.
scatter_kws (dict, optional) – Additional keyword arguments to pass to the scatter plot function.
fontdict (dict, optional) – Font dictionary for the labels. If None, a default fontdict is used.
rcparams (dict, optional) – Dictionary to update matplotlib’s rcParams for customizing plots.
- Returns:
Only if ax is None, the figure containing the plot is returned.
- Return type:
matplotlib.figure.Figure
- evomap.printer.draw_shepard_diagram(X, D, ax=None, show_grid=False, show_rank_correlation=True)[source]#
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.
- evomap.printer.validate_inputs(X_t, color_t, incl_t, n_samples)[source]#
Validate the shape and consistency of inputs.
- evomap.printer.prepare_transparencies(n_periods, start, end, final)[source]#
Prepare transparency values for the plotting periods.
- evomap.printer.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)[source]#
Visualizes dynamic map data over multiple periods with options to show movement paths and adjust visual features.
- Parameters:
X_t (list of ndarray) – List of arrays containing coordinates for each period, where each array is of shape (n_samples, n_features).
color_t (list of ndarray, optional) – List of arrays containing color or group identifiers for each period.
size_t (list of ndarray, optional) – List of arrays containing sizes for each data point in each period.
incl_t (list of ndarray, optional) – List of arrays indicating if a point should be included in the plot for each period.
show_arrows (bool, optional) – If True, display arrows showing movement between periods. Default is False.
show_last_positions_only (bool, optional) – If True, only the last period’s positions are shown with arrows indicating the movements from prior periods. Default is False.
time_labels (list of str, optional) – Labels for each period, displayed in plot annotations or titles.
transparency_start (float, optional) – Starting transparency level for the first period in the dynamic map.
transparency_end (float, optional) – Ending transparency level just before the last period in the dynamic map.
transparency_final (float, optional) – Transparency level for the last period in the dynamic map.
**kwargs (dict) – Additional keyword arguments to pass to the plotting function or for configuring plot aspects.
- Returns:
The figure containing the dynamic map, only if not plotted on an existing axis.
- Return type:
matplotlib.figure.Figure
- evomap.printer.plot_data(X, colors, sizes, inclusions, labels, transparency_start, transparency_end, transparency_final, period, n_periods, ax, show_last_positions_only)[source]#
Helper function to manage data plotting for each period.
- evomap.printer.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)[source]#
Draw the trajectories of selected objects.
- Parameters:
Y_ts (list of ndarrays, each of shape (n_samples, d)) – Sequence of map coordinates.
labels (ndarray of shape (n_samples,)) – Object labels (str)
selected_labels (ndarray of shape (n_selected,), optional) – Selected object labels (str), by default None
title (str, optional) – Figure title, by default None
annotate_periods (bool, optional) – If true, labels for each period are shown next to each pair of map coordinates, by default True
period_labels (ndarray of shape (n_periods,), optional) – Period labels (str), by default None
ax (matplotlib.axes.Axes, optional) – Pre-existing axes for the plot, by default None
figsize (tuple, optional) – Figure size, by default (12,12)
- evomap.printer.fit_attribute(coords, attribute_label, attribute_values, ax, coord_range)[source]#
Fit an attribute to the map and display the resultant vector.
- evomap.printer.fit_attributes(map_coords, df_attributes, ax)[source]#
Fit multiple attributes and display their vectors on the map.
- evomap.printer.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)[source]#
Draw a sequence of static maps next to each other.
- Parameters:
X_t (list of ndarray) – List of arrays containing map coordinates for each period.
color_t (list of ndarray, optional) – Color for each data point per period.
size_t (list of ndarray, optional) – Size for each data point per period.
incl_t (list of ndarray, optional) – Inclusion array to filter points for each period.
n_cols (int, optional) – Maximum number of maps shown in one row.
time_labels (list of str, optional) – Labels for each period, displayed as titles.
show_axes (bool, optional) – Show axes of the plot.
show_box (bool, optional) – Show a box around the plot.
axes_at_origin (bool, optional) – Draw axes lines through the origin.
show_grid (bool, optional) – Show grid lines on the plot.
cmap (str or Colormap, optional) – Colormap to use for coloring the points.
fontdict (dict, optional) – Font dictionary for the labels.
scatter_kws (dict, optional) – Additional keyword arguments to pass to the scatter plot function.
**kwargs (dict) – Additional keyword arguments for figure creation and styling.
- Returns:
The figure containing the sequence of maps.
- Return type:
matplotlib.figure.Figure