Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to set y-axis of raw value plot to the limits of the color map plot #484

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions evo/common_ape_rpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions evo/main_ape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one space too much

"of the color map plot (default: autoscaling)")
output_opts.add_argument(
"--plot_full_ref",
action="store_true",
Expand Down
10 changes: 10 additions & 0 deletions evo/tools/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct type is: typing.Optional[typing.Tuple[float, float]]

subplot_arg: int = 111, linestyle: str = "-",
marker: typing.Optional[str] = None):
"""
Expand All @@ -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
Expand All @@ -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']
Expand All @@ -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)
Expand Down