Skip to main content

Package for easy plotting of ASE atoms using matplotlib

Project description

Atoms_plotter

Package for plotting ASE atoms-objects using matplotlib. Can be used to create vector graphics, or used interactively in a jupyter-notebook.

Installation

clone repository into Atoms_plotter install with

cd Atoms_plotter
python3 -m pip install -e . 

Ideally with a development install (-e) so changes are easily updated.

Usage

  • use installed entry point plot_atoms. See plot_atoms --help for options

In a python script

Initialize the class; set options either when initialising or modify class attributes.

from AtomsPlotter.atoms_plotter import atoms_plotter
from ase.io import read
from sys import argv
atoms=read(argv[1])
ap=atoms_plotter(atoms,show=True)
ap.plot()

In a jupyter-notebook

import ase
import ase.io
import matplotlib.pyplot
atoms=ase.io.read('CONTCAR')
%matplotlib widget #for interactive use
from AtomsPlotter.atoms_plotter import atoms_plotter

plotter=atoms_plotter(atoms=atoms, constraints=True)
plotter.dimension='3D'
plotter.atoms=atoms
plotter.plot()

some options

plotter.scale=70
plotter.bondlinewidth=2
plotter.colorbonds=True
plotter.constraints=False #draw constraints as x
plotter.draw_outline=True
plotter.repeat=[2,2]
plotter.use_bondorders=True #double/triple bonds
plotter.dimension='2D' #2D projection
plotter.plot()

#plot lewis-like structures. bonds as simple black lines, no atoms.

plotter.dimension='2D'
plotter.lewis=True
plotter.scale=0
plotter.atoms.rotate(90, 'z',rotate_cell=True)
plotter.view=2
plotter.plot()

Changelog

0.3.3

  • Fix plot_atoms_2D / plot_atoms_3D colour assignment: elements missing from color_dict (e.g. Au, Pt) used to inherit the last-iterated atom's jmol colour because self.COLORS was rebuilt inside the per-atom loop with the outer-loop atomic number as the fallback. Now built once with a per-atom jmol fallback.
  • Add Au (gold) to the default color_dict.
  • Promote plot_atom_colorscaling to a real constructor keyword (plot_atom_colorscaling=False by default). Previously it was referenced from both render paths but the __init__ assignment was commented out, so any code that hit the color_dict=None branch raised AttributeError.
  • Guard the z-fraction colour scaling against z_norm == 0 so flat (2-D) structures no longer divide by zero.
  • Tidy four ruff E702 (semicolon-chained statements) in check_pbc.

(0.3.2 was prepared but never published — its scope is included in 0.3.3 above.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atomsplotter-0.3.3.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atomsplotter-0.3.3-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file atomsplotter-0.3.3.tar.gz.

File metadata

  • Download URL: atomsplotter-0.3.3.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atomsplotter-0.3.3.tar.gz
Algorithm Hash digest
SHA256 f95411142c0387ec4d99dd4d129d44a715a6e6b5992241d171f36f3c23af88c3
MD5 61b9041599f6649fcb223bd884ab2a53
BLAKE2b-256 411eee22a3bfda71ebe06448832e423f91c2089904862050d435ac22d2dd0a0e

See more details on using hashes here.

File details

Details for the file atomsplotter-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: atomsplotter-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atomsplotter-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 410754463ca7632fe15d24964bd65db6cb0a1a93276ae108a23ffd8200004175
MD5 c3d98b2c1cc2b20c585bf02afccbf3e6
BLAKE2b-256 14389883e5623c2dca61a5efee7aee3d280d7c157e8d162a19d1a6d24fc4c935

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page