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

Fix the visualization in case of a signal with only one datapoint #91

Merged
merged 1 commit into from
Dec 18, 2024
Merged
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
4 changes: 2 additions & 2 deletions robot_log_visualizer/file_reader/signal_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def __populate_numerical_data(self, file_object):
continue
if "data" in value.keys():
data[key] = {}
data[key]["data"] = np.squeeze(np.array(value["data"]))
data[key]["timestamps"] = np.squeeze(np.array(value["timestamps"]))
data[key]["data"] = np.atleast_1d(np.squeeze(np.array(value["data"])))
data[key]["timestamps"] = np.atleast_1d(np.squeeze(np.array(value["timestamps"])))

# if the initial or end time has been updated we can also update the entire timestamps dataset
if data[key]["timestamps"][0] < self.initial_time:
Expand Down
24 changes: 17 additions & 7 deletions robot_log_visualizer/plotter/matplotlib_viewer_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,23 @@ def update_plots(self, paths, legends):

timestamps = data["timestamps"] - self.signal_provider.initial_time

(self.active_paths[path_string],) = self.axes.plot(
timestamps,
datapoints,
label=legend_string,
picker=True,
color=next(self.color_palette),
)
if timestamps.size > 1:
(self.active_paths[path_string],) = self.axes.plot(
timestamps,
datapoints,
label=legend_string,
picker=True,
color=next(self.color_palette),
)
else:
(self.active_paths[path_string],) = self.axes.plot(
timestamps,
datapoints,
label=legend_string,
picker=True,
color=next(self.color_palette),
marker="o",
)

paths_to_be_canceled = []
for active_path in self.active_paths.keys():
Expand Down
Loading