pymatgen
pymatgen copied to clipboard
Are there any plans on adding plotly based plotting codes to pymatgen (or to the optional requirements) in the future?
This might be useful for future plotting codes such as the periodic heatmap plotter. It may be useful to have interactive features for the periodic heatmap to compete with some similar codes outside of pymatgen.
I am all for adding plot.ly based GUIs. But as a longer term strategy, we probably cannot be implementing GUIs on a regular basis as frameworks and code changes.
My suggestion is to think of a "universal" plot data container, e.g., a Pandas Dataframe. Then we implement a few things that translate the universal container to matplotlib or plot.ly/Dash. Of course, matplotlib and Dash already supports most of Dataframe by default. Then we require all pymatgen plot generators (Phase Diagrams, DOS, Bandstructure, etc.) to basically return a pandas dataframe, possibly with some metadata (beyond what pandas already implements).
@mkhorton Thoughts?
Yes, I have two specific thoughts on this:
-
The current limitation with a lot of the pymatgen plotting methods is that they output a matplotlib plot directly rather than an intermediate format. This makes re-plotting with alternative tools difficult. So I agree, a common plot data container will be convenient -- whether pandas or otherwise.
-
For plot.ly specifically, plot.ly graph objects are a JSON-format, so in principle they could work as this intermediate format. For an example, see here.
@richardtran415 with regards to the periodic heatmap plotter, I saw the plot.ly example here. Was there another good example you've seen of this in another code?
The interactive periodic heatmap was just something I have heard about previously in some of the MP meetings. I just thought it might be nifty to have an interactive version of the heatmap on util/plotting.py since it was brought up a couple of times
I agree. The one advantage of making plot.ly an explicit dependency is that we could have interactive plots in Jupyter -- not just periodic table heatmaps, but phase diagrams, band structures, etc. Will have a think of the best way we could structure this. (@montoyjh reminded me of the dataframe plotting functionality in matminer too, perhaps there's a way we could structure this into a common library)
I definitely agree there should be a common plot containner for all plotting devices on pymatgen instead of just a pyplot object. This not only allows users to go back and forth between a static and interactive plot as said, but it also allows for better user customization of certain plots.
I was just wondering since there was a lot of interest over interactive plotting with hotlinks and such for datapoints on the website, it might be easier to transition to such utilities if there were some plot.ly implementations on pymatgen first.
Ok, I may prototype something out ... I'm considering a Plottable mixin that may do some of what we've talked about.
I was just wondering since there was a lot of interest over interactive plotting with hotlinks and such for datapoints on the website, it might be easier to transition to such utilities if there were some plot.ly implementations on pymatgen first.
Yes, completely agreed with this!
A brief update on this: we're continuing to prototype Plotly versions of pymatgen plots in the new crystal toolkit (in collab with @mattmcdermott), once these are stable + look nice the intent is to merge them back into pymatgen via a new standardized plot API (Plottable).
To re-iterate, advantage of Plotly is: (1) it has a canonical JSON representation, so it's easy for us to store, and means we can write adaptors for other plotting tools in future if we want to (2) they have nice auto-matplotlib conversion so we can still support matplotlib for people who want matplotlib without extra effort (3) it produces interactive plots, which is especially nice in Jupyter.
Another (late) update on this: I am working on finishing an overhaul of phase diagram plotting (using Plotly) and will be making a WIP pull request in the upcoming days!
@mattmcdermott Did your PR solve this issue? can it be closed?
@jdagdelen I'm not sure we ever truly overhauled plotting in pymatgen, but I think we're getting there slowly? Not sure I can say whether this issue should be closed or not.
I'm fine with closing it. It sounds like this is going to be an ongoing effort in the long run anyways, and besides, the installation of plotly in the requirements.txt means we can just add on more data containers compatible with plotly and matplotlib in the future if need be.
On Thu, Jul 8, 2021 at 3:02 PM Matthew McDermott @.***> wrote:
@jdagdelen https://github.com/jdagdelen I'm not sure we ever truly overhauled plotting in pymatgen, but I think we're getting there slowly? Not sure I can comment on whether this issue should be closed or not.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/materialsproject/pymatgen/issues/1288#issuecomment-876673575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5J5VQUHXU45NE4MKJY4LTTWXY4ZANCNFSM4FWXZBYA .
--
Richard Tran Phone: (415) 425-7660 Email: r @.***
I can offer this matplotlib version of a periodic table heatmap plot. it's not interactive of course and I've been considering writing a Plotly version for a while. Wasn't aware of this thread before but if there's still interest, I could tackle that sooner.
That looks nice. We have a matplotlib periodic plotting already in pymatgen.utils but I'm sure it could be improved.
pymatgen now uses the interactive plotly periodic table heatmap in pymatviz if it's installed. See #3180.