GithubHelp home page GithubHelp logo

Comments (2)

sgbaird avatar sgbaird commented on May 11, 2024 1

Ok, this is more what I should be going for I think:

import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 3)
[plot_structure_2d(s, ax=ax) for s, ax in zip(train_structures.tolist(), axes)]

image

from pymatviz.

janosh avatar janosh commented on May 11, 2024 1

I don't think there's a way for plot_structure_2d() to be smart about this since it can't know how many structures there are to plot in total and what the figure's axes layout should be.

Ok, this is more what I should be going for I think:

Yes, that's the intended usage. There are 2 somewhat hidden examples of this:

fig, axs = plt.subplots(3, 4, figsize=(12, 12))
for struct, ax in zip(df_perov.structure.head(12), axs.flat):
ax = plot_structure_2d(struct, ax=ax)
ax.set_title(struct.composition.reduced_formula, fontsize=14)

df_phonons = load_dataset("matbench_phonons")
n_rows, n_cols = 3, 4
fig, axs = plt.subplots(n_rows, n_cols, figsize=(3 * n_rows, 3 * n_cols))
for struct, ax in zip(df_phonons.structure.head(n_rows * n_cols), axs.flat):
ax = plot_structure_2d(struct, ax=ax)
spg_symbol, _ = struct.get_space_group_info()
formula = struct.composition.reduced_formula
ax.set_title(f"{formula} ({spg_symbol})", fontweight="bold")

Should probably add a multi-axes example to the plot_structure_2d() doc string to make it more discoverable.

from pymatviz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.