From d0dd37f96fbe420cef84910d590e27da4be2cf9a Mon Sep 17 00:00:00 2001 From: Breno Cunha Queiroz Date: Mon, 16 Feb 2026 18:23:32 +0100 Subject: [PATCH] fix: add assertion for n_ticks minimum when labels provided --- implot.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implot.cpp b/implot.cpp index f2f7f40c..76f23b07 100644 --- a/implot.cpp +++ b/implot.cpp @@ -2247,6 +2247,8 @@ void SetupAxisTicks(ImAxis idx, double v_min, double v_max, int n_ticks, const c ImPlotContext& gp = *GImPlot; IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr && !gp.CurrentPlot->SetupLocked, "Setup needs to be called after BeginPlot and before any setup locking functions (e.g. PlotX)!"); + IM_ASSERT_USER_ERROR(labels == nullptr || n_ticks >= 2, + "When providing custom labels, n_ticks must be at least 2!"); n_ticks = n_ticks < 2 ? 2 : n_ticks; FillRange(gp.TempDouble1, n_ticks, v_min, v_max); SetupAxisTicks(idx, gp.TempDouble1.Data, n_ticks, labels, show_default);