Skip to content

Commit

Permalink
fix scalings plot label
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhundhausen committed Jan 29, 2024
1 parent c1dbeb3 commit 08287a9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions menu_tools/object_performance/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ def __init__(
self.version = version
self.scaling_pct = scaling_pct

def _params_to_func_str(self, obj):
a = round(self.params[obj][0], 3)
b = round(self.params[obj][1], 3)
def _params_to_func_str(self, obj_key: str):
a = round(self.params[obj_key][0], 3)
b = round(self.params[obj_key][1], 3)
pm = "+" if b > 0 else "-"
return f"y = {a} x {pm} {abs(b)}"

Expand All @@ -363,13 +363,14 @@ def plot(self):
self._make_output_dirs(self.version)

fig, ax = self._create_new_plot()
for obj, points in self.scalings.items():
for obj_key, points in self.scalings.items():
obj = Object(obj_key, self.version)
x_points = np.array(list(points.keys()))
y_points = np.array(list(points.values()))
pts = ax.plot(x_points, y_points, "o")

label = obj + ", " + self._params_to_func_str(obj) # TODO: Fix label!
a, b = self.params[obj]
label = obj.plot_label + ", " + self._params_to_func_str(obj_key)
a, b = self.params[obj_key]
x = np.linspace(0, 2500, 20)
y = utils.scaling_func(x, a, b)
ax.plot(x, y, color=pts[0].get_color(), label=label)
Expand Down

0 comments on commit 08287a9

Please sign in to comment.