Plotting module¶
Plotting module.
- MARBLE.plotting.fields(data, titles=None, col=1, figsize=(8, 8), axlim=None, axes_visible=False, color=None, alpha=0.5, node_size=10, plot_gauges=False, width=0.005, edge_width=1.0, scale=5, view=None)[source]¶
Plot scalar or vector fields
- Parameters:
data – PyG Batch data object class created with utils.construct_dataset
titles – list of titles
col – int for number of columns to plot
figsize – tuple of figure dimensions
- MARBLE.plotting.histograms(data, titles=None, col=2, figsize=(10, 10))[source]¶
Plot histograms of cluster distribution across datasets.
- Parameters:
data – PyG Batch data object class created with utils.construct_dataset
clusters – sklearn cluster object
titles – list of titles
col – int for number of columns to plot
figsize – tuple of figure dimensions
- MARBLE.plotting.embedding(data, labels=None, titles=None, mask=None, ax=None, alpha=0.3, s=5, axes_visible=False, cbar_visible=True, clusters_visible=False, cmap='coolwarm', plot_trajectories=False, style='o', lw=1, time_gradient=False)[source]¶
Plot embeddings.
- Parameters:
data – PyG data object with attribute emb or nxdim matrix of embedded points with dim=2 or 3
labels – list of increasing integer node labels
clusters – sklearn cluster object
titles – list of titles
- MARBLE.plotting.neighbourhoods(data, hops=1, cols=4, norm=False, color=None, plot_graph=False, figsize=(15, 20), fontsize=20, width=0.025, scale=1)[source]¶
For each clustered neighbourhood type, draw one sample neighbourhood from each dataset.
- Parameters:
data – postprocessed PyG Batch data object class created with utils.construct_dataset
hops – size of neighbourhood in number of hops
norm – if True, then normalise values to zero mean within clusters
plot_graph – if True, then plot the underlying graph.
- MARBLE.plotting.graph(G, labels='b', edge_width=1, edge_alpha=1.0, node_size=20, layout=None, ax=None, axes_visible=True)[source]¶
Plot scalar values on graph nodes embedded in 2D or 3D.
- MARBLE.plotting.trajectories(X, V=None, ax=None, style='o', node_feature=None, lw=1, ms=5, scale=1, arrow_spacing=1, axes_visible=True, alpha=1.0)[source]¶
Plot trajectory in phase space. If multiple trajectories are given, they are plotted with different colors.
- Parameters:
X (np array) – Positions
V (np array) – Velocities
ax (matplotlib axes object) – If specificed, it will plot on existing axes. Default is None
style (string) – Plotting style. ‘o’ for scatter plot or ‘-’ for line plot
node_feature – Color lines. The default is None
lw (int) – Line width
ms (int) – Marker size
scale (float) – Scaling of arrows
arrow_spacing (int) – How many timesteps apart are the arrows spaced.
axes_visible (bool) – Whether to display axes
alpha (float) – transparancy of the markers
- Returns:
matplotlib axes object.
- MARBLE.plotting.plot_arrows(pos, signal, ax, c='k', alpha=1.0, width=1.0, scale=1.0)[source]¶
Plot arrows.
- class MARBLE.plotting.Arrow3D(xs, ys, zs, *args, **kwargs)[source]¶
Arrow 3D.
There are two ways for defining an arrow:
If posA and posB are given, a path connecting two points is created according to connectionstyle. The path will be clipped with patchA and patchB and further shrunken by shrinkA and shrinkB. An arrow is drawn along this resulting path using the arrowstyle parameter.
Alternatively if path is provided, an arrow is drawn along this path and patchA, patchB, shrinkA, and shrinkB are ignored.
- Parameters:
posA ((float, float), default: None) – (x, y) coordinates of arrow tail and arrow head respectively.
posB ((float, float), default: None) – (x, y) coordinates of arrow tail and arrow head respectively.
path (~matplotlib.path.Path, default: None) – If provided, an arrow is drawn along this path and patchA, patchB, shrinkA, and shrinkB are ignored.
arrowstyle – The .ArrowStyle with which the fancy arrow is drawn. If a string, it should be one of the available arrowstyle names, with optional comma-separated attributes. The optional attributes are meant to be scaled with the mutation_scale. The following arrow styles are available:
- connectionstylestr or .ConnectionStyle or None, optional, default: ‘arc3’
The .ConnectionStyle with which posA and posB are connected. If a string, it should be one of the available connectionstyle names, with optional comma-separated attributes. The following connection styles are available:
Class
Name
Attrs
Arc3
arc3
rad=0.0
Angle3
angle3
angleA=90, angleB=0
Angle
angle
angleA=90, angleB=0, rad=0.0
Arc
arc
angleA=0, angleB=0, armA=None, armB=None, rad=0.0
Bar
bar
armA=0.0, armB=0.0, fraction=0.3, angle=None
- patchA, patchB~matplotlib.patches.Patch, default: None
Head and tail patches, respectively.
- shrinkA, shrinkBfloat, default: 2
Shrink amount, in points, of the tail and head of the arrow respectively.
- mutation_scalefloat, default: 1
Value with which attributes of arrowstyle (e.g., head_length) will be scaled.
- mutation_aspectNone or float, default: None
The height of the rectangle will be squeezed by this value before the mutation and the mutated box will be stretched by the inverse of it.
- Parameters:
**kwargs (~matplotlib.patches.Patch properties, optional) – Here is a list of available .Patch properties:
Properties –
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: unknown animated: bool antialiased or aa: bool or None capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None color: :mpltype:`color` edgecolor or ec: :mpltype:`color` or None facecolor or fc: :mpltype:`color` or None figure: ~matplotlib.figure.Figure or ~matplotlib.figure.SubFigure fill: bool gid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} hatch_linewidth: unknown in_layout: bool joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} label: object linestyle or ls: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …} linewidth or lw: float or None mouseover: bool path_effects: list of .AbstractPathEffect picker: None or bool or float or callable rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float
In contrast to other patches, the default
capstyle
andjoinstyle
for FancyArrowPatch are set to"round"
.
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, arrowstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, connectionstyle=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, patchA=<UNSET>, patchB=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)¶
Set multiple properties at once.
Supported properties are
- Properties:
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool antialiased or aa: bool or None arrowstyle: [ ‘-’ | ‘<-’ | ‘->’ | ‘<->’ | ‘<|-' | '-|>’ | ‘<|-|>’ | ‘]-’ | ‘-[’ | ‘]-[’ | ‘|-|’ | ‘]->’ | ‘<-[’ | ‘simple’ | ‘fancy’ | ‘wedge’ ] capstyle: .CapStyle or {‘butt’, ‘projecting’, ‘round’} clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None color: :mpltype:`color` connectionstyle: [ ‘arc3’ | ‘angle3’ | ‘angle’ | ‘arc’ | ‘bar’ ] edgecolor or ec: :mpltype:`color` or None facecolor or fc: :mpltype:`color` or None figure: ~matplotlib.figure.Figure or ~matplotlib.figure.SubFigure fill: bool gid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} hatch_linewidth: unknown in_layout: bool joinstyle: .JoinStyle or {‘miter’, ‘round’, ‘bevel’} label: object linestyle or ls: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …} linewidth or lw: float or None mouseover: bool mutation_aspect: float mutation_scale: float patchA: .patches.Patch patchB: .patches.Patch path_effects: list of .AbstractPathEffect picker: None or bool or float or callable positions: unknown rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float