| 69 | } |
| 70 | |
| 71 | fn validate_regular_grid(n_plots: usize, rows: usize, cols: usize) { |
| 72 | if n_plots == 0 { |
| 73 | panic!( |
| 74 | "SubplotGrid validation error: plots vector cannot be empty.\n\ |
| 75 | \n\ |
| 76 | Problem: You provided an empty plots vector.\n\ |
| 77 | Solution: Create at least one plot and add it to the plots vector.\n\ |
| 78 | \n\ |
| 79 | Example:\n\ |
| 80 | let plot1 = ScatterPlot::builder().data(&df).x(\"x\").y(\"y\").build();\n\ |
| 81 | SubplotGrid::regular().plots(vec![&plot1])\n\ |
| 82 | .build();" |
| 83 | ); |
| 84 | } |
| 85 | |
| 86 | if rows == 0 { |
| 87 | panic!( |
| 88 | "SubplotGrid validation error: rows must be greater than 0.\n\ |
| 89 | \n\ |
| 90 | Problem: You specified rows = 0, but rows must be at least 1.\n\ |
| 91 | Solution: Set rows to a positive integer (e.g., 1, 2, or 3).\n\ |
| 92 | \n\ |
| 93 | Example:\n\ |
| 94 | SubplotGrid::regular()\n\ |
| 95 | .plots(vec![&plot1])\n\ |
| 96 | .rows(2) // Use positive integer\n\ |
| 97 | .cols(2)\n\ |
| 98 | .build();" |
| 99 | ); |
| 100 | } |
| 101 | |
| 102 | if cols == 0 { |
| 103 | panic!( |
| 104 | "SubplotGrid validation error: cols must be greater than 0.\n\ |
| 105 | \n\ |
| 106 | Problem: You specified cols = 0, but cols must be at least 1.\n\ |
| 107 | Solution: Set cols to a positive integer (e.g., 1, 2, or 3).\n\ |
| 108 | \n\ |
| 109 | Example:\n\ |
| 110 | SubplotGrid::regular()\n\ |
| 111 | .plots(vec![&plot1])\n\ |
| 112 | .rows(2)\n\ |
| 113 | .cols(2) // Use positive integer\n\ |
| 114 | .build();" |
| 115 | ); |
| 116 | } |
| 117 | |
| 118 | let grid_capacity = rows * cols; |
| 119 | |
| 120 | if n_plots > grid_capacity { |
| 121 | panic!( |
| 122 | "SubplotGrid validation error: too many plots for grid size.\n\ |
| 123 | \n\ |
| 124 | Problem: You provided {} plot(s) but the grid only has {} cells ({}x{} = {}).\n\ |
| 125 | Solution: Either reduce the number of plots or increase the grid size.\n\ |
| 126 | \n\ |
| 127 | Option 1 - Reduce plots:\n\ |
| 128 | Use {} plots instead of {}\n\ |