@@ -1272,6 +1272,10 @@ void Demo_SubplotsSizing() {
1272
1272
static int cols = 3 ;
1273
1273
ImGui::SliderInt (" Rows" ,&rows,1 ,5 );
1274
1274
ImGui::SliderInt (" Cols" ,&cols,1 ,5 );
1275
+ if (rows < 1 || cols < 1 ) {
1276
+ ImGui::TextColored (ImVec4 (1 ,0 ,0 ,1 ), " Nice try, but the number of rows and columns must be greater than 0!" );
1277
+ return ;
1278
+ }
1275
1279
static float rratios[] = {5 ,1 ,1 ,1 ,1 ,1 };
1276
1280
static float cratios[] = {5 ,1 ,1 ,1 ,1 ,1 };
1277
1281
ImGui::DragScalarN (" Row Ratios" ,ImGuiDataType_Float,rratios,rows,0 .01f ,nullptr );
@@ -1281,7 +1285,9 @@ void Demo_SubplotsSizing() {
1281
1285
if (ImPlot::BeginPlot (" " ,ImVec2 (),ImPlotFlags_NoLegend)) {
1282
1286
ImPlot::SetupAxes (nullptr ,nullptr ,ImPlotAxisFlags_NoDecorations,ImPlotAxisFlags_NoDecorations);
1283
1287
float fi = 0 .01f * (i+1 );
1284
- ImPlot::SetNextLineStyle (SampleColormap ((float )i/(float )(rows*cols-1 ),ImPlotColormap_Jet));
1288
+ if (rows*cols > 1 ) {
1289
+ ImPlot::SetNextLineStyle (SampleColormap ((float )i/(float )(rows*cols-1 ),ImPlotColormap_Jet));
1290
+ }
1285
1291
ImPlot::PlotLineG (" data" ,SinewaveGetter,&fi,1000 );
1286
1292
ImPlot::EndPlot ();
1287
1293
}
0 commit comments