Skip to content

Commit 3f26b66

Browse files
Enhance data handling in SignalProvider and improve plotting behavior in MatplotlibViewerCanvas in case of signal with only one datapoint (#91)
1 parent 76e2c97 commit 3f26b66

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

robot_log_visualizer/file_reader/signal_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def __populate_numerical_data(self, file_object):
126126
continue
127127
if "data" in value.keys():
128128
data[key] = {}
129-
data[key]["data"] = np.squeeze(np.array(value["data"]))
130-
data[key]["timestamps"] = np.squeeze(np.array(value["timestamps"]))
129+
data[key]["data"] = np.atleast_1d(np.squeeze(np.array(value["data"])))
130+
data[key]["timestamps"] = np.atleast_1d(np.squeeze(np.array(value["timestamps"])))
131131

132132
# if the initial or end time has been updated we can also update the entire timestamps dataset
133133
if data[key]["timestamps"][0] < self.initial_time:

robot_log_visualizer/plotter/matplotlib_viewer_canvas.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,23 @@ def update_plots(self, paths, legends):
201201

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

204-
(self.active_paths[path_string],) = self.axes.plot(
205-
timestamps,
206-
datapoints,
207-
label=legend_string,
208-
picker=True,
209-
color=next(self.color_palette),
210-
)
204+
if timestamps.size > 1:
205+
(self.active_paths[path_string],) = self.axes.plot(
206+
timestamps,
207+
datapoints,
208+
label=legend_string,
209+
picker=True,
210+
color=next(self.color_palette),
211+
)
212+
else:
213+
(self.active_paths[path_string],) = self.axes.plot(
214+
timestamps,
215+
datapoints,
216+
label=legend_string,
217+
picker=True,
218+
color=next(self.color_palette),
219+
marker="o",
220+
)
211221

212222
paths_to_be_canceled = []
213223
for active_path in self.active_paths.keys():

0 commit comments

Comments
 (0)