epezent / implot

Immediate Mode Plotting
MIT License
4.55k stars 503 forks source link

Heatmap bound not respected with col-major flag #510

Closed cwahn closed 10 months ago

cwahn commented 11 months ago

Hey guys.

I found a possible bug. The min and max of the heatmap are not respected.
So I fixed the bounds to (0, 0) and (1, 1) for a test. If I went through the source code right, the drawing should be bounded in rectangles of (0, 0) and (1, 1). However, it is not as one can see below.

It seems like only the y of max and x of min bounds get respected. And have no idea how the others are determined.

        PlotHeatmap(
            y_name_.c_str(),
            p_data(ass_view_),
            plot_length_,               // rows on display? yes
            sample_length_,             // rows on display?? yes
            minimum(ass_view_),         // color map min?
            maximum(ass_view_),         // color map max?
            NULL,                       // fmt
            ImPlotPoint(0, 0),          // coordinate of view in unit of limits
            ImPlotPoint(1, 1),          // coordinate of view in unit of limits
            ImPlotHeatmapFlags_ColMajor // col-major = col-contiguous memory
        );

https://github.com/epezent/implot/assets/80148667/3bd2c15f-c087-4b04-ad57-7bffb43e15f4

What should I check out? Is this an actual bug? (please disregard the log info at the bottom of the plot. They are temporarily plotting some other info)

-- EDIT 23. 08. 28 19:29 Actually it works as expected without column major flag. https://github.com/epezent/implot/assets/80148667/65ad0b45-77a5-423e-b5df-4d5f65664c79

It might be a bug of column major flag.

cwahn commented 11 months ago

I found the reason.

It was the indexing logic of the GetterHeatmapColMaj::operator(). Please review the PR I made.

https://github.com/epezent/implot/pull/511