Skip to content

Isolines in show_slice #49

Description

@dvd101x

Hi,

This is not an issue, just a proposal to include isolines as other 2D representations of SDF.

Change this
Image

To something like this

Image

The change in code is not that much, this is an example.

def show_slice(*args, **kwargs):
    import matplotlib.pyplot as plt
    from matplotlib.colors import TwoSlopeNorm
    a, extent, axes = sample_slice(*args, **kwargs)
    norm = TwoSlopeNorm(vmin=a.min(), vcenter=0, vmax=a.max())
    im = plt.imshow(a, extent=extent, origin='lower', cmap="PRGn", norm=norm)
    plt.contour(a, colors='white', alpha=0.5, extent=extent)  # Add semi-transparent isolines
    plt.contour(a, levels=[0], colors='black', extent=extent)  # Add isoline at 0
    plt.xlabel(axes[0])
    plt.ylabel(axes[1])
    plt.colorbar(im)
    plt.show()

The idea is to use a diverging color map centered at 0, add isonlines shown in white and add a single isoline shown in black representing the boundary of the solid.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions