Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wulff plot not working #2900

Closed
cedenoruel opened this issue Mar 20, 2023 · 4 comments · Fixed by #2950
Closed

Wulff plot not working #2900

cedenoruel opened this issue Mar 20, 2023 · 4 comments · Fixed by #2950
Labels
bug data viz PRs and issues about pymatgen plotting functionality

Comments

@cedenoruel
Copy link

The Bug

The wulff.show() function which normally gives a static plot no longer works.
Instead, it returns <Figure size 576x576 with 0 Axes>
However, wulff.get_plotly() works (which gives an interactive plot).

To Reproduce

!pip install pymatgen
# Import the neccesary tools to generate surfaces
from pymatgen.core.surface import SlabGenerator, generate_all_slabs, Structure, Lattice
# Import the neccesary tools for making a Wulff shape
from pymatgen.analysis.wulff import WulffShape

lattice = Lattice.cubic(3.508)
Ni = Structure(
    lattice,
    ["Ni", "Ni", "Ni", "Ni"],
    [[0, 0, 0], [0, 0.5, 0], [0.5, 0, 0], [0, 0, 0.5]],)
surface_energies_Ni = {
    (3, 2, 0): 2.3869,
    (1, 1, 0): 2.2862,
    (3, 1, 0): 2.3964,
    (2, 1, 0): 2.3969,
    (3, 3, 2): 2.0944,
    (1, 0, 0): 2.2084,
    (2, 1, 1): 2.2353,
    (3, 2, 2): 2.1242,
    (3, 2, 1): 2.3183,
    (2, 2, 1): 2.1732,
    (3, 3, 1): 2.2288,
    (3, 1, 1): 2.3039,
    (1, 1, 1): 1.9235,
}
miller_list = surface_energies_Ni.keys()
e_surf_list = surface_energies_Ni.values()

# We can now construct a Wulff shape with an accuracy up to a max Miller index of 3
wulffshape = WulffShape(Ni.lattice, miller_list, e_surf_list)

# Let's get some useful information from our wulffshape object
print(
    "shape factor: %.3f, anisotropy: \
%.3f, weighted surface energy: %.3f J/m^2"
    % (
        wulffshape.shape_factor,
        wulffshape.anisotropy,
        wulffshape.weighted_surface_energy,
    )
)


# If we want to see what our Wulff shape looks like
wulffshape.show()

  • OS: (Windows 10)
  • Platform: Google Colab
@janosh
Copy link
Member

janosh commented Apr 19, 2023

Bug confirmed.

@CifLord Are you familiar with this code? If you have time, maybe you could take look?

@janosh janosh added bug data viz PRs and issues about pymatgen plotting functionality labels Apr 19, 2023
@CifLord
Copy link
Contributor

CifLord commented Apr 19, 2023

Yeah I can take a look, thanks for letting me know!

@CifLord
Copy link
Contributor

CifLord commented Apr 22, 2023

Made a pull request to fix this. @cedenoruel do you know what version of matplotlib you're using? If its 3.6.0 or higher, its not compatible with the Wulffshape plotter. In any case, the pull request should fix the compatibility issue now

@cedenoruel
Copy link
Author

cedenoruel commented Apr 26, 2023

Made a pull request to fix this. @cedenoruel do you know what version of matplotlib you're using? If its 3.6.0 or higher, its not compatible with the Wulffshape plotter. In any case, the pull request should fix the compatibility issue now

@CifLord @janosh Now, it's working again. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug data viz PRs and issues about pymatgen plotting functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants