Skip to content

Conversation

@huangchieh
Copy link
Contributor

@huangchieh huangchieh commented Nov 4, 2025

Fix #370 Now, the parameter edge is enabled. In some cases, when the scanning range is large, one can use edge=False to disable edge drawing. Then the correct color for the atoms reveal.

...
afmulator.plot_images(X=X, outdir=outfolder, prefix=f'df_atoms_depth{depth}', atoms=atoms_formatted, edge=False)
...
df_atoms_depth5_030

@huangchieh huangchieh changed the title enable edge parameter in plotImage funciton. fix #370 enable edge parameter in plotImage funciton. Nov 4, 2025
@huangchieh huangchieh changed the title enable edge parameter in plotImage funciton. Enable edge parameter in plotImage. Nov 4, 2025
@huangchieh huangchieh changed the title Enable edge parameter in plotImage. Enable edge parameter in plotImage. Nov 4, 2025
@NikoOinonen
Copy link
Collaborator

Is this how you want it without the edges at all? We could also just adjust the width of the edge line to be thinner. Or arguably the size of the image should be larger with such a large unit cell, so we could automatically adjust the resolution based on the unit cell size, which would also make the edge lines adjust at the same time.

@huangchieh
Copy link
Contributor Author

The main motivation is simply to distinguish different atoms by color. When the simulation cell becomes large, it would be nice to have the option to disable edge drawing entirely to avoid the appearance of black dots.

I tried passing the lw parameter to plt.Circle as follows:

def plotAtoms(atoms, atomSize=default_atom_size, edge=True, ec="k", color="w", lw=1.0):
    plt.fig = plt.gcf()
    atoms[0]
    xs = atoms[1]
    ys = atoms[2]
    if len(atoms) > 4:
        colors = atoms[4]
    else:
        colors = [color] * 100
    for i in range(len(atoms[1])):
        fc = "#%02x%02x%02x" % colors[i]
        if not edge:
            ec = fc
        circle = plt.Circle((xs[i], ys[i]), atomSize, fc=fc, ec=ec, lw=lw)
        plt.fig.gca().add_artist(circle)

With lw=0.5,
df_atoms_depth5_030

Since the atom size in the image is quite small, using a thinner line width still makes it difficult to distinguish the colors. In this case, setting the edge color to match the fill color actually gives a cleaner visual result than reducing the line width.

Ideally, the edge width could be adjusted automatically based on the cell size. To achieve this, we might need to pass the cell information to plotAtoms and scale both the edge width and atom size accordingly, so that atoms remain clearly visible for large unit cells.

@NikoOinonen
Copy link
Collaborator

Ideally, the edge width could be adjusted automatically based on the cell size. To achieve this, we might need to pass the cell information to plotAtoms and scale both the edge width and atom size accordingly, so that atoms remain clearly visible for large unit cells.

I forget how matplotlib treats this, but it might be enough to just scale up the figsize in plotImages, if you could try that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overlay atoms color optimization.

2 participants