Skip to content

discrete colorer in 2D phase diagrams #16

Description

@jdelpino

Something in the lines of this snippet should do the trick

using Plots
gr()

# Sample data with discrete values
x = LinRange(-2, 2, 100)
y = LinRange(-2, 2, 100)
z = [round(xi^2 + yi^2) for xi in x, yi in y]  # Discrete values`

# Identify unique values in z
unique_vals = sort(unique(vec(z)))

# Plot with one level per unique value
heatmap(x, y, z;
    levels = length(unique_vals),
    clims = (minimum(unique_vals), maximum(unique_vals)),
    c = :viridis,
    colorbar = true,
    colorbar_ticks = (unique_vals, string.(unique_vals))  # Optional: label each tick
)

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions