evomap.printer
Contents
evomap.printer
#
Useful functions to draw maps.
Module Contents#
Functions#
|
Draw a single (static) map. Can take additional scatterplot arguments |
|
Draw a sequence of static maps next to each other. Can use the same |
|
Fit an attribute to the map and display the resultant vector. |
|
Fit multiple attributes and display their vectors in the map. |
|
Draw a dynamic map, jointly visualizing all object's map coordinates |
|
Draw the trajectories of selected objects. |
|
Set default aesthetic styles here. References: Matplotlib RC params |
Attributes#
- evomap.printer.DEFAULT_BUBBLE_SIZE = 25#
- evomap.printer.DEFAULT_FONT_SIZE = 10#
- evomap.printer.draw_map(Y, c=None, size=None, labels=None, highlight_labels=None, inclusions=None, zoom_on_cluster=None, annotate=None, filename=None, ax=None, fig_size=None, show_box=True, cmap=None, rcparams=None, title_str=None, fontdict=None, title_fontdict=None, scatter_kws={})[source]#
Draw a single (static) map. Can take additional scatterplot arguments as kwargs, see https://matplotlib.org/3.5.0/api/_as_gen/matplotlib.pyplot.scatter.html#matplotlib.pyplot.scatter
- Parameters
Y (ndarray of shape (n_samples, d)) – Map coordinates. If d = 1, the resultant map is a line. If d > 2, only the first two dimensions are visualized.
c (ndarray of shape (n_samples,), optional) – Cluster assignments used for coloring (int), by default None
labels (ndarray of shape (n_samples,), optional) – Object labels (str), by default None
highlight_labels (list, optional) – Labels which should be highligted on the map, by default None
inclusions (ndarray of shape (n_samples,), optional) – Inlcusion array. A 0 indicates that the object should be excluded on the map, a 1 indicates that the object should be included in the map , by default None
zoom_on_cluster (int, optional) – Cluster number on which the map should be zoomed-in to, by default None
annotate (str, optional) – Annotations, either None, ‘labels’, or ‘clusters’, by default None
filename (str, optional) – Filename to which the map is saved, by default None
ax (matplotlib.axes.Axes, optional) – Pre-existing axes for the plot., by default None
fig_size (tuple (int,int), optional) – Figure size, by default None
show_box (bool, optional) – If true, a box is drawn around the map, by default True
cmap (str, optional) – The colormap for coloring the cluster assignments. Should be a valid colormap Name, or a custom colormap function by default None
rcparams (dict, optional) – Dictionary of matplotlib rcParams, by default None
fontdict (dict, optional) – Dictionary defining the label font, by default None
- evomap.printer.draw_map_sequence(Y_ts, c_ts=None, n_cols=4, time_labels=[], **kwargs)[source]#
Draw a sequence of static maps next to each other. Can use the same arguments as the ‘draw_map’ function as dictionary.
- Parameters
Y_ts (list of ndarrays, each of shape (n_samples, d)) – Sequence of map coordinates.
c_ts (list of ndarray, each of shape (n_samples,), optional) – Sequence of cluster assignments used for coloring (int), by default None If the cluster assignments are constant, one can simply provide a single array as kwarg.
n_cols (int, optional) – Max. number of maps shown in one row, by default 4
map_kws (dict, optional) – Additional arguments for the ‘draw_map’ function, by default None
time_labels (list of str, optional) – When given, use these labels as title strings
- evomap.printer.fit_attribute(coords, attribute_label, attribute_values, map)[source]#
Fit an attribute to the map and display the resultant vector.
To do so, regress the attribute value on map coordinates and use the coefficients as arrow coordinates.
- Parameters
coords (ndarray of shape (n_samples, n_dims)) – Map coordinates.
attribute_label (string) – Attribute label (displayed next to vector).
attribute_values (ndarray of shape (n_samples,)) – Attribute values for each sample.
map (matplotlib.figure) – Figure containing the map (i.e., output of draw_map function)
- Returns
Figure containing the map with property vector added.
- Return type
matplotlib.figure
- evomap.printer.fit_attributes(map_coords, df_attributes, map)[source]#
Fit multiple attributes and display their vectors in the map.
- Parameters
map_coords (ndarray of shape (n_samples, n_dims)) – Map coordinates.
df_attributes (pd.DataFrame) – Dataframe containing the attributes. Each column is expected to correspond to one attribute. Make sure to label colums and that the number of rows equals n_samples.
map (matplotlib.figure) – Figure containing the map (i.e., output of draw_map function)
- Returns
Figure containing the map with property vectors added.
- Return type
matplotlib.figure
- evomap.printer.draw_dynamic_map(Y_ts, c_ts=None, incl_ts=None, show_arrows=False, show_last_positions_only=False, highlight_trajectories=None, transparency_start=0.1, transparency_end=0.4, transparency_final=1.0, **kwargs)[source]#
Draw a dynamic map, jointly visualizing all object’s map coordinates over time. Can take all arguments of ‘draw_map’ as kwargs.
- Parameters
Y_ts (list of ndarrays, each of shape (n_samples, d)) – Sequence of map coordinates.
c_ts (list of ndarray, each of shape (n_samples,), optional) – Sequence of cluster assignments used for coloring (int), by default None If the cluster assignments are constant, one can simply provide a single array as kwarg.
incl_ts (list of ndarrays, each of shape (n_samples, ), optional) – Sequence of inclusion arrays, each indicating if an object is present in period t (via 0 and 1s), by default None
show_arrows (bool, optional) – If true, objects’ subsequent positions are connected by arrows, by default False
show_last_positions_only (bool, optional) – If true, only the map positions for the last period are displayed. Should be combined with ‘show arrows = True’, by default False
highlight_trajectories (list, optional) – Labels for which trajectories should be highlighted, by default None
transparency_start (float, optional) – Transparency of bubbles for first period, by default 0.1
transparency_end (float, optional) – Transparency of bubbles for second-last period, by default 0.4
transparency_final (float, optional) – transparency of bubbles for last period, by default 1.
- evomap.printer.draw_trajectories(Y_ts, labels, selected_labels=None, title_str=None, annotate_periods=True, period_labels=None, ax=None, figsize=None)[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 (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)