Skip to content

Heatmap / Image / Surface API clarification and nonlinear grids #748

@jkrumbiegel

Description

@jkrumbiegel

We had multiple issues about nonlinear grids for heatmaps, but also about the bin centering of heatmaps and images (basically that pixel [1, 1] is not centered on point [1, 1]).

These discussions have mostly looked at implementing things in the backends, but I think it's an AbstractPlotting abstraction issue. Right now, there is a SurfaceLike trait which heatmap, image and surface use to convert their arguments. I think that this is incorrect, because they are different, even if only in a subtle way.

The difference is that a surface colors the vertices of a grid, while image / heatmap colors the cells of a grid. I therefore suggest to remove SurfaceLike and instead add VertexSurfaceLike and CellSurfaceLike or something else to that effect. Maybe there are better words for this.

Then the question is how the coordinates of these grids should be defined. Let's say our color data are always in the form of a matrix, then there are multiple different ways of defining the coordinates of vertices / cells.

Here's what I would suggest:

x & y coordinates example type interpretation VertexSurfaceLike interpretation CellSurfaceLike
1.0..10.0 ClosedInterval n linspaced vertices from 1 to 10 n equal-sized cells with centers from 1 to 10
1:10 Range 10 linspaced vertices from 1 to 10 (must match n), basically like vector 10 equal-sized cells with centers from 1 to 10 (must match n), basically like vector
[1, 2, 3] Vector 3 vertices (should be sorted?), can be nonlinear, must match n 3 cell centers (should be sorted?), cells always extend halfway to neighbor (mirror outward at edges), must match n

Matrices would then just be extensions of the vector case.

One thing that this doesn't cover is a plot where the coordinates given are vertices, but the colors are for the cells. One could dispatch to that method by checking if the length of heatmap coordinates are n+1, but that might be a bit brittle?

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