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

Function Demo_Histogram2D

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

Source from the content-addressed store, hash-verified

886//-----------------------------------------------------------------------------
887
888void Demo_Histogram2D() {
889 IMGUI_DEMO_MARKER("Plots/Histogram 2D");
890 static int count = 50000;
891 static int xybins[2] = {100,100};
892
893 static ImPlotHistogramFlags hist_flags = 0;
894
895 ImGui::SliderInt("Count",&count,100,100000);
896 ImGui::SliderInt2("Bins",xybins,1,500);
897 ImGui::SameLine();
898 ImGui::CheckboxFlags("Density", (unsigned int*)&hist_flags, ImPlotHistogramFlags_Density);
899
900 static NormalDistribution<100000> dist1(1, 2);
901 static NormalDistribution<100000> dist2(1, 1);
902 double max_count = 0;
903 ImPlotAxisFlags flags = ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_Foreground;
904 ImPlot::PushColormap("Hot");
905 if (ImPlot::BeginPlot("##Hist2D",ImVec2(ImGui::GetContentRegionAvail().x-100-ImGui::GetStyle().ItemSpacing.x,0))) {
906 ImPlot::SetupAxes(nullptr, nullptr, flags, flags);
907 ImPlot::SetupAxesLimits(-6,6,-6,6);
908 max_count = ImPlot::PlotHistogram2D("Hist2D",dist1.Data,dist2.Data,count,xybins[0],xybins[1],ImPlotRect(-6,6,-6,6), {ImPlotProp_Flags, hist_flags});
909 ImPlot::EndPlot();
910 }
911 ImGui::SameLine();
912 ImPlot::ColormapScale(hist_flags & ImPlotHistogramFlags_Density ? "Density" : "Count",0,max_count,ImVec2(100,0));
913 ImPlot::PopColormap();
914}
915
916//-----------------------------------------------------------------------------
917

Callers

nothing calls this directly

Calls 12

SliderIntFunction · 0.85
SliderInt2Function · 0.85
PushColormapFunction · 0.85
BeginPlotFunction · 0.85
ImVec2Function · 0.85
SetupAxesFunction · 0.85
SetupAxesLimitsFunction · 0.85
PlotHistogram2DFunction · 0.85
ImPlotRectClass · 0.85
EndPlotFunction · 0.85
ColormapScaleFunction · 0.85
PopColormapFunction · 0.85

Tested by

no test coverage detected