diff --git a/evo/common_ape_rpe.py b/evo/common_ape_rpe.py index db6b5902..8fdf4158 100644 --- a/evo/common_ape_rpe.py +++ b/evo/common_ape_rpe.py @@ -134,13 +134,22 @@ def plot_result(args: argparse.Namespace, result: Result, traj_ref: PosePath3D, x_array = None x_label = "index" + if args.plot_colormap_min is None: + args.plot_colormap_min = result.stats["min"] + if args.plot_colormap_max is None: + args.plot_colormap_max = result.stats["max"] + + y_lim = (None, None) + if args.plot_raw_with_same_limits_as_colormap: + y_lim = (args.plot_colormap_min, args.plot_colormap_max) + plot.error_array( fig1.gca(), result.np_arrays["error_array"], x_array=x_array, statistics={ s: result.stats[s] for s in SETTINGS.plot_statistics if s not in ("min", "max") }, name=result.info["label"], title=result.info["title"], - xlabel=x_label) + xlabel=x_label, ylim=y_lim) # Plot the values color-mapped onto the trajectory. fig2 = plt.figure(figsize=SETTINGS.plot_figsize) @@ -155,10 +164,6 @@ def plot_result(args: argparse.Namespace, result: Result, traj_ref: PosePath3D, plot.draw_coordinate_axes(ax, traj_ref, plot_mode, SETTINGS.plot_reference_axis_marker_scale) - if args.plot_colormap_min is None: - args.plot_colormap_min = result.stats["min"] - if args.plot_colormap_max is None: - args.plot_colormap_max = result.stats["max"] if args.plot_colormap_max_percentile is not None: args.plot_colormap_max = np.percentile( result.np_arrays["error_array"], args.plot_colormap_max_percentile) diff --git a/evo/main_ape.py b/evo/main_ape.py index ab60f2a8..8f0d4565 100755 --- a/evo/main_ape.py +++ b/evo/main_ape.py @@ -95,6 +95,10 @@ def parser() -> argparse.ArgumentParser: help="percentile of the error distribution to be used " "as the upper bound of the color map plot " "(in %%, overrides --plot_colormap_max)") + output_opts.add_argument( + "--plot_raw_with_same_limits_as_colormap", type=bool, + help="set y-axis of raw value plot to the limits " + "of the color map plot (default: autoscaling)") output_opts.add_argument( "--plot_full_ref", action="store_true", diff --git a/evo/tools/plot.py b/evo/tools/plot.py index b42d9aa9..78903484 100644 --- a/evo/tools/plot.py +++ b/evo/tools/plot.py @@ -595,6 +595,7 @@ def error_array(ax: plt.Axes, err_array: ListOrArray, threshold: float = None, cumulative: bool = False, color: str = 'grey', name: str = "error", title: str = "", xlabel: str = "index", ylabel: typing.Optional[str] = None, + xlim: typing.Tuple[float, float] = None, ylim: typing.Tuple[float, float] = None, subplot_arg: int = 111, linestyle: str = "-", marker: typing.Optional[str] = None): """ @@ -609,6 +610,8 @@ def error_array(ax: plt.Axes, err_array: ListOrArray, :param title: optional plot title :param xlabel: optional x-axis label :param ylabel: optional y-axis label + :param xlim: optional tuple of x-axis limits + :param ylim: optional tuple of y-axis limits :param subplot_arg: optional matplotlib subplot ID if used as subplot :param linestyle: matplotlib linestyle :param marker: optional matplotlib marker style for points @@ -627,6 +630,12 @@ def error_array(ax: plt.Axes, err_array: ListOrArray, else: ax.plot(err_array, linestyle=linestyle, marker=marker, color=color, label=name) + + if xlim is not None: + ax.set_xlim(xlim) + if ylim is not None: + ax.set_ylim(ylim) + if statistics is not None: for stat_name, value in statistics.items(): color = next(ax._get_lines.prop_cycler)['color'] @@ -640,6 +649,7 @@ def error_array(ax: plt.Axes, err_array: ListOrArray, if threshold is not None: ax.axhline(y=threshold, color='red', linestyle='dashed', linewidth=2.0, label="threshold") + plt.ylabel(ylabel if ylabel else name) plt.xlabel(xlabel) plt.title(title)