Plot to matplotlib subplot
It would be nice to be able to plot atomic structures generated with ASE as a matplotlib subplot, which would make to tailor atomic structure plots to a very large degree.
I made a simple function which does this using the ase.io.png/eps:
from ase.io.png import PNG
def get_rgba_image_array(ase_atoms_object, **parameters):
png_plot = PNG(ase_atoms_object, **parameters)
png_plot.write_header()
png_plot.write_body()
rgba_buffer = png_plot.renderer.buffer_rgba()
image_data = np.frombuffer(rgba_buffer, np.uint8)
image_data = image_data.reshape(int(png_plot.h),int(png_plot.w),4)
return(image_data)
image_data = get_rgba_image_array(slab, radii=radii)
ax.imshow(image_data)
However, this does not work optimally, as it is plotting the raster output potentially leads to low-res images.
So I could implement a simple "matplotlib-subplot-writer", which would use the functionality already implemented in https://gitlab.com/ase/ase/blob/master/ase/io/eps.py#L174. It would take the same input parameters as the EPS function, but it would output a matplotlib subplot object instead.
Where would the appropriate place to put something like this? ase.io?
Original thread on the mailing list: https://listserv.fysik.dtu.dk/pipermail/ase-users/2016-June/003033.html