r""" Gives arrays xr, yr that can be plotted over an (n, m) imshow plot (in 'xy' coordinates). If `a_y` or `b_y` is provided, y is sliced over its indices such that y stays in [ay, by]. Parameters ---------- x : ndarray, shape (nx,) y : ndarray, shape (nx,) n : int
(x, y, n, m=None, a_y=None, b_y=None)
| 164 | |
| 165 | |
| 166 | def rescale_for_imshow_plot(x, y, n, m=None, a_y=None, b_y=None): |
| 167 | r""" |
| 168 | Gives arrays xr, yr that can be plotted over an (n, m) |
| 169 | imshow plot (in 'xy' coordinates). If `a_y` or `b_y` is provided, |
| 170 | y is sliced over its indices such that y stays in [ay, by]. |
| 171 | |
| 172 | Parameters |
| 173 | ---------- |
| 174 | x : ndarray, shape (nx,) |
| 175 | y : ndarray, shape (nx,) |
| 176 | n : int |
| 177 | x-axis size of the imshow plot on which to plot (x, y) |
| 178 | m : int, optional |
| 179 | y-axis size of the imshow plot, defaults to n |
| 180 | a_y : float, optional |
| 181 | Lower bound for y |
| 182 | b_y : float, optional |
| 183 | Upper bound for y |
| 184 | |
| 185 | Returns |
| 186 | ------- |
| 187 | xr : ndarray, shape (nx,) |
| 188 | Rescaled x values (due to slicing, may have less elements than x) |
| 189 | yr : ndarray, shape (nx,) |
| 190 | Rescaled y values (due to slicing, may have less elements than y) |
| 191 | |
| 192 | See Also |
| 193 | -------- |
| 194 | :func:`plot1D_mat` |
| 195 | |
| 196 | """ |
| 197 | # slice over the y values that are in the y range |
| 198 | a_x, b_x = np.min(x), np.max(x) |
| 199 | assert x.shape[0] == y.shape[0], "x and y arrays should have the same size" |
| 200 | if a_y is None: |
| 201 | a_y = np.min(y) |
| 202 | if b_y is None: |
| 203 | b_y = np.max(y) |
| 204 | if m is None: |
| 205 | m = n |
| 206 | idx = (y >= a_y) & (y <= b_y) |
| 207 | x_rescaled = (x[idx] - a_x) * (n - 1) / (b_x - a_x) |
| 208 | y_rescaled = (y[idx] - a_y) * (m - 1) / (b_y - a_y) |
| 209 | return x_rescaled, y_rescaled |
| 210 | |
| 211 | |
| 212 | def plot2D_samples_mat(xs, xt, G, thr=1e-8, **kwargs): |
no test coverage detected