Skip to content

Commit 3c98edc

Browse files
Add the possibility to plot scalar signal
1 parent f7f299b commit 3c98edc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

robot_log_visualizer/plotter/matplotlib_viewer_canvas.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ def update_plots(self, paths, legends):
7676
data = self.signal_provider.data
7777
for key in path[:-1]:
7878
data = data[key]
79-
datapoints = data["data"][:, int(path[-1])]
79+
try:
80+
datapoints = data["data"][:, int(path[-1])]
81+
except IndexError:
82+
# This happens in the case the variable is a scalar.
83+
datapoints = data["data"][:]
84+
8085
timestamps = data["timestamps"] - self.signal_provider.initial_time
8186

8287
(self.active_paths[path_string],) = self.axes.plot(

robot_log_visualizer/ui/gui.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,11 @@ def __populate_variable_tree_widget(self, obj, parent) -> QTreeWidgetItem:
335335
return parent
336336
if "data" in obj.keys() and "timestamps" in obj.keys():
337337
temp_array = obj["data"]
338-
n_cols = temp_array.shape[1]
338+
try:
339+
n_cols = temp_array.shape[1]
340+
except IndexError:
341+
# This happens in the case the variable is a scalar.
342+
n_cols = 1
339343

340344
# In yarp telemetry v0.4.0 the elements_names was saved.
341345
if "elements_names" in obj.keys():

0 commit comments

Comments
 (0)