[ase-users] Plot to matplotlib subplot
Magnus Nord
magnus.nord at glasgow.ac.uk
Fri Jun 3 12:45:26 CEST 2016
I can make a simple implementation of this, which would be very similar
to the write eps/png function. Which would take an Atoms object, and
return a subplot with the plot.
I'll open an "Issue" about it on GitLab.
Magnus
On 03/06/16 11:28, Ask Hjorth Larsen wrote:
>
> Hi
>
> There are a couple of places in ASE where plots are generated
> "willy-nilly", where it would be a clear advantage to take axes as
> argument. It is definitely a good idea to make that change.
>
> Best regards
> Ask
>
> El 03/06/2016 11:13, "Simon Rittmeyer via ase-users"
> <ase-users at listserv.fysik.dtu.dk
> <mailto:ase-users at listserv.fysik.dtu.dk>> escribió:
>
> 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
> <mailto: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
> <mailto:ase-users at listserv.fysik.dtu.dk>
> > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> <mailto:ase-users at listserv.fysik.dtu.dk>
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20160603/c00914e4/attachment.html>
More information about the ase-users
mailing list