MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / Demo_Heatmaps

Function Demo_Heatmaps

Source/3rdParty/implot/implot_demo.cpp:752–816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750//-----------------------------------------------------------------------------
751
752void Demo_Heatmaps() {
753 IMGUI_DEMO_MARKER("Plots/Heatmaps");
754 static float values1[7][7] = {{0.8f, 2.4f, 2.5f, 3.9f, 0.0f, 4.0f, 0.0f},
755 {2.4f, 0.0f, 4.0f, 1.0f, 2.7f, 0.0f, 0.0f},
756 {1.1f, 2.4f, 0.8f, 4.3f, 1.9f, 4.4f, 0.0f},
757 {0.6f, 0.0f, 0.3f, 0.0f, 3.1f, 0.0f, 0.0f},
758 {0.7f, 1.7f, 0.6f, 2.6f, 2.2f, 6.2f, 0.0f},
759 {1.3f, 1.2f, 0.0f, 0.0f, 0.0f, 3.2f, 5.1f},
760 {0.1f, 2.0f, 0.0f, 1.4f, 0.0f, 1.9f, 6.3f}};
761 static float scale_min = 0;
762 static float scale_max = 6.3f;
763 static const char* xlabels[] = {"C1","C2","C3","C4","C5","C6","C7"};
764 static const char* ylabels[] = {"R1","R2","R3","R4","R5","R6","R7"};
765
766 static ImPlotColormap map = ImPlotColormap_Viridis;
767 if (ImPlot::ColormapButton(ImPlot::GetColormapName(map),ImVec2(225,0),map)) {
768 map = (map + 1) % ImPlot::GetColormapCount();
769 // We bust the color cache of our plots so that item colors will
770 // resample the new colormap in the event that they have already
771 // been created. See documentation in implot.h.
772 BustColorCache("##Heatmap1");
773 BustColorCache("##Heatmap2");
774 }
775
776 ImGui::SameLine();
777 ImGui::LabelText("##Colormap Index", "%s", "Change Colormap");
778 ImGui::SetNextItemWidth(225);
779 ImGui::DragFloatRange2("Min / Max",&scale_min, &scale_max, 0.01f, -20, 20);
780
781 static ImPlotHeatmapFlags hm_flags = 0;
782
783 ImGui::CheckboxFlags("Column Major", (unsigned int*)&hm_flags, ImPlotHeatmapFlags_ColMajor);
784
785 static ImPlotAxisFlags axes_flags = ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks;
786
787 ImPlot::PushColormap(map);
788
789 if (ImPlot::BeginPlot("##Heatmap1",ImVec2(ImGui::GetTextLineHeight()*14,ImGui::GetTextLineHeight()*14),ImPlotFlags_NoLegend|ImPlotFlags_NoMouseText)) {
790 ImPlot::SetupAxes(nullptr, nullptr, axes_flags, axes_flags);
791 ImPlot::SetupAxisTicks(ImAxis_X1,0 + 1.0/14.0, 1 - 1.0/14.0, 7, xlabels);
792 ImPlot::SetupAxisTicks(ImAxis_Y1,1 - 1.0/14.0, 0 + 1.0/14.0, 7, ylabels);
793 ImPlot::PlotHeatmap("heat",values1[0],7,7,scale_min,scale_max,"%g",ImPlotPoint(0,0),ImPlotPoint(1,1), {ImPlotProp_Flags, hm_flags});
794 ImPlot::EndPlot();
795 }
796 ImGui::SameLine();
797 ImPlot::ColormapScale("##HeatScale",scale_min, scale_max, ImVec2(60,225));
798
799 ImGui::SameLine();
800
801 const int size = 80;
802 static double values2[size*size];
803 srand((unsigned int)(ImGui::GetTime()*1000000));
804 for (int i = 0; i < size*size; ++i)
805 values2[i] = RandomRange(0.0,1.0);
806
807 if (ImPlot::BeginPlot("##Heatmap2",ImVec2(ImGui::GetTextLineHeight()*14,ImGui::GetTextLineHeight()*14))) {
808 ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_NoDecorations, ImPlotAxisFlags_NoDecorations);
809 ImPlot::SetupAxesLimits(-1,1,-1,1);

Callers

nothing calls this directly

Calls 15

ColormapButtonFunction · 0.85
GetColormapNameFunction · 0.85
ImVec2Function · 0.85
GetColormapCountFunction · 0.85
BustColorCacheFunction · 0.85
LabelTextFunction · 0.85
DragFloatRange2Function · 0.85
PushColormapFunction · 0.85
BeginPlotFunction · 0.85
SetupAxesFunction · 0.85
SetupAxisTicksFunction · 0.85
PlotHeatmapFunction · 0.85

Tested by

no test coverage detected