erlab.plotting.atoms¶
Plot atoms.
Classes and functions for plotting atoms and bonds in a crystal structure using matplotlib’s 3D plotting capabilities.
Some of the projection code was adapted from kwant.
Classes
|
A collection of 3D scatter points that represents atoms in a crystal structure. |
|
A collection of 3D lines that represents bonds in a crystal structure. |
|
- class erlab.plotting.atoms.Atom3DCollection(*args, scale_size=True, **kwargs)[source]¶
Bases:
Path3DCollectionA collection of 3D scatter points that represents atoms in a crystal structure.
This class is not for direct instantiation, but is used to patch the collection returned by the
scattermethod. See the implementation ofCrystalProperty.plotfor usage.- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, depthshade=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sizes=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, sort_zpos=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]¶
Set multiple properties at once.
Supported properties are
- Properties:
3d_properties: float or array of floats 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: array-like or float or None animated: bool antialiased or aa or antialiaseds: bool or list of bools array: array-like or None capstyle:
CapStyleor {‘butt’, ‘projecting’, ‘round’} clim: (vmin: float, vmax: float) clip_box:BboxBaseor None clip_on: bool clip_path: Patch or (Path, Transform) or None cmap:Colormapor str or None color: color or list of RGBA tuples depthshade: bool edgecolor or ec or edgecolors: color or list of color or ‘face’ facecolor or facecolors or fc: color or list of color figure:FigureorSubFiguregid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} hatch_linewidth: unknown in_layout: bool joinstyle:JoinStyleor {‘miter’, ‘round’, ‘bevel’} label: object linestyle or dashes or linestyles or ls: str or tuple or list thereof linewidth or linewidths or lw: float or list of floats mouseover: bool norm:Normalizeor str or None offset_transform or transOffset:Transformoffsets: (N, 2) or (2,) array-like path_effects: list ofAbstractPathEffectpaths: unknown picker: None or bool or float or callable pickradius: float rasterized: bool sizes: unknown sketch_params: (scale: float, length: float, randomness: float) snap: bool or None sort_zpos: unknown transform:Transformurl: str urls: list of str or None visible: bool zorder: float
- class erlab.plotting.atoms.Bond3DCollection(segments, *, scale_linewidths=True, **kwargs)[source]¶
Bases:
Line3DCollectionA collection of 3D lines that represents bonds in a crystal structure.
- Parameters:
segments – List of segments representing the bonds.
scale_linewidths (
bool, default:True) – Boolean indicating whether to scale the linewidths based on the plot’s perspective.**kwargs – Additional keyword arguments to be passed to
mpl_toolkits.mplot3d.art3d.Line3DCollection.
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, array=<UNSET>, capstyle=<UNSET>, clim=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, cmap=<UNSET>, color=<UNSET>, colors=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, gapcolor=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, norm=<UNSET>, offset_transform=<UNSET>, offsets=<UNSET>, path_effects=<UNSET>, paths=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, segments=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, sort_zpos=<UNSET>, transform=<UNSET>, url=<UNSET>, urls=<UNSET>, verts=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]¶
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: array-like or float or None animated: bool antialiased or aa or antialiaseds: bool or list of bools array: array-like or None capstyle:
CapStyleor {‘butt’, ‘projecting’, ‘round’} clim: (vmin: float, vmax: float) clip_box:BboxBaseor None clip_on: bool clip_path: Patch or (Path, Transform) or None cmap:Colormapor str or None color: color or list of color colors: color or list of color edgecolor or ec or edgecolors: color or list of color or ‘face’ facecolor or facecolors or fc: color or list of color figure:FigureorSubFiguregapcolor: color or list of color or None gid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} hatch_linewidth: unknown in_layout: bool joinstyle:JoinStyleor {‘miter’, ‘round’, ‘bevel’} label: object linestyle or dashes or linestyles or ls: str or tuple or list thereof linewidth or linewidths or lw: unknown mouseover: bool norm:Normalizeor str or None offset_transform or transOffset:Transformoffsets: (N, 2) or (2,) array-like path_effects: list ofAbstractPathEffectpaths: unknown picker: None or bool or float or callable pickradius: float rasterized: bool segments: unknown sketch_params: (scale: float, length: float, randomness: float) snap: bool or None sort_zpos: unknown transform:Transformurl: str urls: list of str or None verts: unknown visible: bool zorder: float
- class erlab.plotting.atoms.CrystalProperty(atom_pos, avec, offset=(0.0, 0.0, 0.0), radii=None, colors=None, repeat=(1, 1, 1), bounds=None, mask=None, r_factor=0.4)[source]¶
Bases:
object- plot(ax=None, scale_bonds=True, scale_atoms=True, clean_axes=True, bond_kw=None, atom_kw=None)[source]¶
Plot the crystal structure.
- Parameters:
ax (
Axes3D|None, default:None) – A 3D axes object to plot the crystal on. If not provided, add_subplot will be called on the current figure.scale_bonds (
bool, default:True) – Whether to scale the bond linewidths based on the distance from the camera, by default Truescale_atoms (
bool, default:True) – Whether to scale the atom sizes based on the distance from the camera, by default Trueclean_axes (
bool, default:True) – Whether to clean the axes by removing the background and grid, setting pane color, and removing the margins, by default Truebond_kw (
dict|None, default:None) – Keyword arguments passed ontoBond3DCollectionatom_kw (
dict|None, default:None) – Keyword arguments passed ontompl_toolkits.mplot3d.Axes3D.scatterused to plot the atoms.