@@ -79,7 +79,6 @@ def __init__(
7979 # figures for creating 2D plots
8080 max_num_figs = 3
8181 self .figs = []
82- self .figs_viewport = []
8382 width_adjustment = width % 4
8483 fig_w , fig_h = int (width / 4 ), int (height / 4 )
8584 for idx in range (max_num_figs ):
@@ -88,11 +87,6 @@ def __init__(
8887 fig .flg_extend = 1
8988 self .figs .append (fig )
9089
91- x = int (3 * width / 4 ) + width_adjustment
92- y = idx * fig_h
93- vp = mujoco .MjrRect (x , y , fig_w , fig_h )
94- self .figs_viewport .append (vp )
95-
9690 # load camera from configuration (if available)
9791 pathlib .Path (
9892 self .CONFIG_PATH .parent ).mkdir (
@@ -174,7 +168,7 @@ def add_data_to_line(self, line_name, line_data, fig_idx = 0):
174168 "line name is not valid, add it to list before calling update"
175169 )
176170
177- pnt = min (201 , fig .linepnt [line_idx ] + 1 )
171+ pnt = min (mujoco . mjMAXLINEPNT , fig .linepnt [line_idx ] + 1 )
178172 # shift data
179173 for i in range (pnt - 1 , 0 , - 1 ):
180174 fig .linedata [line_idx ][2 * i + 1 ] = fig .linedata [line_idx ][2 * i - 1 ]
@@ -396,14 +390,6 @@ def update():
396390 width , height = glfw .get_framebuffer_size (self .window )
397391 self .viewport .width , self .viewport .height = width , height
398392
399- fig_w , fig_h = int (width / 4 ), int (height / 4 )
400- width_adjustment = width % 4
401- for idx in range (len (self .figs_viewport )):
402- x = int (3 * width / 4 ) + width_adjustment
403- y = idx * fig_h
404- vp = mujoco .MjrRect (x , y , fig_w , fig_h )
405- self .figs_viewport [idx ] = vp
406-
407393 with self ._gui_lock :
408394 # update scene
409395 mujoco .mjv_updateScene (
@@ -434,9 +420,15 @@ def update():
434420 t2 ,
435421 self .ctx )
436422
437- # Handle graph and pausing interactions
423+ # handle figures
438424 if not self ._hide_graph :
439- for fig , viewport in zip (self .figs , self .figs_viewport ):
425+ for idx , fig in enumerate (self .figs ):
426+ width_adjustment = width % 4
427+ x = int (3 * width / 4 ) + width_adjustment
428+ y = idx * int (height / 4 )
429+ viewport = mujoco .MjrRect (
430+ x , y , int (width / 4 ), int (height / 4 ))
431+
440432 has_lines = len ([i for i in fig .linename if i != b'' ])
441433 if has_lines :
442434 mujoco .mjr_figure (viewport , fig , self .ctx )
0 commit comments