(self, data: Field, figure, subplot, space: Box, min_val: float, max_val: float, show_color_bar: bool, color: Tensor, alpha: Tensor, err: Tensor)
| 225 | return data.is_grid and data.spatial_rank == 1 and not instance(data) |
| 226 | |
| 227 | def plot(self, data: Field, figure, subplot, space: Box, min_val: float, max_val: float, show_color_bar: bool, color: Tensor, alpha: Tensor, err: Tensor): |
| 228 | x = data.center[{'vector': 0, '~vector': 0}].numpy() |
| 229 | requires_legend = False |
| 230 | for c_idx, c_idx_n in zip(channel(data).meshgrid(), channel(data).meshgrid(names=True)): |
| 231 | label = index_label(c_idx_n) |
| 232 | values = data.values.vector.dual[0][c_idx].numpy() |
| 233 | if (color[c_idx] == None).all: |
| 234 | col = _next_line_color(subplot) |
| 235 | else: |
| 236 | col = _plt_col(color[c_idx]) |
| 237 | alpha_f = float(alpha[c_idx]) |
| 238 | if ((err[c_idx] != 0) & (err[c_idx] != None)).any: |
| 239 | v_err = reshaped_numpy(err[c_idx], [spatial(data)]) |
| 240 | subplot.fill_between(x, values - v_err, values + v_err, color=col, alpha=alpha_f * .2) |
| 241 | if values.dtype in (np.complex64, np.complex128): |
| 242 | subplot.plot(x, values.real, label=f"{label} real" if label else "real", color=col, alpha=alpha_f) |
| 243 | subplot.plot(x, values.imag, '--', label=f"{label} imag" if label else "imag", color=col, alpha=alpha_f) |
| 244 | requires_legend = True |
| 245 | else: |
| 246 | subplot.plot(x, values, label=label, color=col, alpha=alpha_f) |
| 247 | requires_legend = requires_legend or label |
| 248 | if requires_legend: |
| 249 | # if not has_legend_like([index_label(idx_n) for idx_n in channel(data.values).meshgrid(names=True)], figure): |
| 250 | subplot.legend() |
| 251 | # elif min_val is not None and max_val is not None: |
| 252 | # subplot.set_ylim((min_val - .02 * (max_val - min_val), max_val + .02 * (max_val - min_val))) |
| 253 | if spatial(data).item_names[0]: # label x ticks |
| 254 | set_ticks(subplot, 0, x, spatial(data).item_names[0]) |
| 255 | |
| 256 | |
| 257 | class BarChart(Recipe): |
no test coverage detected