[ase-users] Plot to matplotlib subplot
Simon Rittmeyer
simon.rittmeyer at tum.de
Fri Jun 3 11:12:27 CEST 2016
Hi Magnus,
I would be very interested. Thought about something like this as well for quite some time. I also have some test code somewhere, but my attempts never made it into anything really usable. Would be great if you could or anyone else could work on it. At least for quick visualization purposes this would be a very neat feature.
Best wishes
Simon
> Am 03.06.2016 um 10:27 schrieb Magnus Nord via ase-users <ase-users at listserv.fysik.dtu.dk>:
>
> Hey,
>
> I'm trying to make plots of several atomic structures within the same matplotlib figure, where they each can have a different orientation or structure.
>
> After digging around in the ase.io.eps and png modules I managed to make a function which does this:
>
> 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 leading to low-res images.
>
> So I am wondering if there is an easier way of doing this?
>
> And, if there isn't: would there be any interest in having such functionality? For example a get_matplotlib_figure(ase_atoms_object) which returns a figure and/or subplots of the structure, where if a subplot or figure is given to the function, the structure is plotted in the given figure and/or subplot.
>
> It would be fairly straight forward to implement this, since all the plotting code is already in the ase.io.eps module.
>
> Magnus
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
More information about the ase-users
mailing list