Some changes to get_graph_label defaults

This commit is contained in:
Grant Sanderson 2021-02-06 11:39:39 -08:00
parent c3ccfbfa65
commit e6fc323b6d

View file

@ -147,15 +147,18 @@ class CoordinateSystem():
direction=RIGHT, direction=RIGHT,
buff=MED_SMALL_BUFF, buff=MED_SMALL_BUFF,
color=None): color=None):
label = Tex(label) if isinstance(label, str):
label = Tex(label)
if color is None: if color is None:
label.match_color(graph) label.match_color(graph)
if x is None: if x is None:
# Searching from the right, find a point # Searching from the right, find a point
# whose y value is in bounds # whose y value is in bounds
max_y = FRAME_Y_RADIUS - label.get_height() max_y = FRAME_Y_RADIUS - label.get_height()
for x0 in np.arange(*self.x_range)[-1::-1]: max_x = FRAME_X_RADIUS - label.get_width()
if abs(self.itgp(x0, graph)[1]) < max_y: for x0 in np.arange(*self.x_range)[::-1]:
pt = self.itgp(x0, graph)
if abs(pt[0]) < max_x and abs(pt[1]) < max_y:
x = x0 x = x0
break break
if x is None: if x is None: