@@ -66,7 +66,9 @@ def __init__(
6666 self .title = title
6767 self .from_datacollector = from_datacollector
6868 self .colors = None
69-
69+
70+ self .padding = 10
71+
7072 self .validate_input ()
7173
7274 if colors is not None :
@@ -108,7 +110,7 @@ def setup(self, figure, renderer):
108110 self .width = self .figure .width
109111 self .height = self .figure .height
110112
111- self .font_size = int (self .height * 0.03 )
113+ self .font_size = int (self .height * 0.025 )
112114
113115 self .plot_area_x = self .x + self .width * 0.15
114116 self .plot_area_y = self .y + self .height * 0.3
@@ -150,23 +152,50 @@ def create_plot_area(self):
150152 self .figure .shape_list .append (outline )
151153
152154 def create_axis_ticks (self ):
155+ min_y_tick_y_pos = self .plot_area_y + self .padding
156+ mid_y_tick_y_pos = self .plot_area_y + self .padding + (self .plot_area_height - self .padding * 2 ) / 2
157+ max_y_tick_y_pos = self .plot_area_y + self .plot_area_height - self .padding
158+
153159 self .min_y_label = arcade .Text (
154160 text = "" ,
155161 x = 0 ,
156- y = self .plot_area_y ,
162+ y = min_y_tick_y_pos - self .font_size / 2 ,
163+ color = arcade .color .BLACK ,
164+ font_size = self .font_size ,
165+ batch = self .figure .text_batch ,
166+ )
167+
168+ self .mid_y_label = arcade .Text (
169+ text = "" ,
170+ x = 0 ,
171+ y = mid_y_tick_y_pos - self .font_size / 2 ,
157172 color = arcade .color .BLACK ,
158173 font_size = self .font_size ,
159174 batch = self .figure .text_batch ,
160175 )
176+
161177 self .max_y_label = arcade .Text (
162178 text = "" ,
163179 x = 0 ,
164- y = self . plot_area_y + self . plot_area_height - self .font_size ,
180+ y = max_y_tick_y_pos - self .font_size / 2 ,
165181 color = arcade .color .BLACK ,
166182 font_size = self .font_size ,
167183 batch = self .figure .text_batch ,
168184 )
169185
186+ for i in range (5 ):
187+ self .figure .shape_list .append (
188+ arcade .shape_list .create_rectangle (
189+ center_x = self .plot_area_x - 2 ,
190+ center_y = min_y_tick_y_pos + (self .plot_area_height - self .padding * 2 ) / 4 * i ,
191+ width = 3 ,
192+ height = 3 ,
193+ color = arcade .color .BLACK ,
194+ ))
195+
196+
197+
198+
170199 def create_legend (self ):
171200 label_x = self .figure .x + self .width * 0.1
172201 label_y = self .plot_area_y - self .height * 0.1
@@ -250,22 +279,21 @@ def update(self):
250279
251280 # Rescale the data
252281 # TODO: Optimize this with numpy
253- padding = 10
254282 self .scaled_data_dict [model_attr ] = [
255283 (
256284 rescale (
257285 value = x ,
258286 old_min = 0 ,
259287 old_max = tick ,
260- new_min = self .plot_area_x + padding ,
261- new_max = self .plot_area_x + self .plot_area_width - padding ,
288+ new_min = self .plot_area_x + self . padding ,
289+ new_max = self .plot_area_x + self .plot_area_width - self . padding ,
262290 ),
263291 rescale (
264292 value = y ,
265293 old_min = self .min_y ,
266294 old_max = self .max_y ,
267- new_min = self .plot_area_y + padding ,
268- new_max = self .plot_area_y + self .plot_area_height - padding ,
295+ new_min = self .plot_area_y + self . padding ,
296+ new_max = self .plot_area_y + self .plot_area_height - self . padding ,
269297 ),
270298 )
271299 for x , y in self .data_dict [model_attr ]
@@ -276,14 +304,23 @@ def update(self):
276304 if self .min_y_label .text != str_min_y_label :
277305 self .min_y_label .text = str_min_y_label
278306 self .min_y_label .x = (
279- self .plot_area_x - (len (str_min_y_label ) + 1 ) * self .font_size / 1.5
307+ self .plot_area_x - (len (str_min_y_label ) + 2 ) * self .font_size / 1.5
280308 )
309+
310+ # update medium y_label
311+ str_mid_y_label = str (round ((self .min_y + self .max_y ) / 2 , 3 ))
312+ if self .mid_y_label .text != str_mid_y_label :
313+ self .mid_y_label .text = str_mid_y_label
314+ self .mid_y_label .x = (
315+ self .plot_area_x - (len (str_mid_y_label ) + 2 ) * self .font_size / 1.5
316+ )
317+
281318 # update upper y_label
282319 str_max_y_label = str (round (self .max_y , 3 ))
283320 if self .max_y_label != str_max_y_label :
284321 self .max_y_label .text = str_max_y_label
285322 self .max_y_label .x = (
286- self .plot_area_x - (len (str_max_y_label ) + 1 ) * self .font_size / 1.5
323+ self .plot_area_x - (len (str_max_y_label ) + 2 ) * self .font_size / 1.5
287324 )
288325
289326 def draw (self ):
0 commit comments