From 0a3442f389409adb8d04c5f73674f7f50e9bfbd2 Mon Sep 17 00:00:00 2001 From: Evan Pezent Date: Sat, 25 Jul 2020 07:52:15 -0500 Subject: [PATCH] fix issue with heatmap bounds not working correctly --- implot.cpp | 2 +- implot_demo.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/implot.cpp b/implot.cpp index 9c630bf..2ddefe3 100644 --- a/implot.cpp +++ b/implot.cpp @@ -3221,7 +3221,7 @@ void RenderHeatmap(Transformer transformer, ImDrawList& DrawList, const T* value for (int c = 0; c < cols; ++c) { ImPlotPoint p; p.x = bounds_min.x + 0.5*w + c*w; - p.y = bounds_min.y + 1 - (0.5*h + r*h); + p.y = bounds_max.y - (0.5*h + r*h); ImVec2 a = transformer(p.x - half_size.x, p.y - half_size.y); ImVec2 b = transformer(p.x + half_size.x, p.y + half_size.y); float t = (float)Remap(values[i], scale_min, scale_max, T(0), T(1)); diff --git a/implot_demo.cpp b/implot_demo.cpp index d17d4fa..c5aefb9 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -412,8 +412,10 @@ void ShowDemoWindow(bool* p_open) { ImGui::SameLine(); static ImVec4 gray[2] = {ImVec4(0,0,0,1), ImVec4(1,1,1,1)}; ImPlot::SetColormap(&gray[0], 2); + ImPlot::SetNextPlotLimits(-1,1,-1,1); if (ImPlot::BeginPlot("##Heatmap2",NULL,NULL,ImVec2(225,225),ImPlotFlags_ContextMenu,0,0)) { - ImPlot::PlotHeatmap("heat",values2,100,100,0,1,NULL); + ImPlot::PlotHeatmap("heat1",values2,100,100,0,1,NULL); + ImPlot::PlotHeatmap("heat1",values2,100,100,0,1,NULL, ImPlotPoint(-1,-1), ImPlotPoint(0,0)); ImPlot::EndPlot(); } ImPlot::SetColormap(ImPlotColormap_Default);