Skip to content

Conversation

@bircni
Copy link
Contributor

@bircni bircni commented Nov 16, 2025

This was originally implemented in emilk/egui#2246 by @JohannesProgrammiert

Now we restart it!

Copy link
Collaborator

@michalsustr michalsustr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, very cool and a nice demo! Left a couple comments, nothing major. Can you pls make sure it passes CI checks?

impl std::error::Error for HeatmapErr {}

/// A heatmap.
pub struct Heatmap<const RESOLUTION: usize> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow, what is the motivation for having a generic here?

I find it weird, particularly when you can also pass custom_mapping and have the generic be irrelevant.

I'd just store the palette in a Vec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just revieved the old code - what would be your suggestion?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pass a palette as a Vec<Color32> and do lookups from the Vec. The RESOLUTION acts basically as histogram binning of the values -> colors mapping, linearly discretizing the ranges of values that fall into the same color. If this feels too complicated I can do it, but prefer if you do.


/// Set color palette by specifying base colors from low to high
#[inline]
pub fn palette(mut self, base_colors: &[Color32]) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just simply store the colors? If user wants finer-grained details, they can use the helper function.
Add it to docs comment as a helpful reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by that?

}

/// Interpolate linear gradient with `RESOLUTION` steps from an arbitrary number of base colors.
fn linear_gradient_from_base_colors(base_colors: &[Color32]) -> [Color32; RESOLUTION] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be extracted out as a public helper function, i.e.
pub fn linear_gradient_from_base_colors(base_colors: &[Color32], resolution: i32) -> Vec<Color32>

/// Highlight all plot elements.
#[inline]
pub fn highlight(mut self, highlight: bool) -> Self {
// FIXME: for some reason highlighting is not detected
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pls take another look?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its working so i think the comment can be removed?

@michalsustr michalsustr self-assigned this Nov 22, 2025
@michalsustr michalsustr changed the title Add heatmap support 2.0 feat: Heatmap support Nov 22, 2025
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.

2 participants